Case-insensitive login, auto-matching after scan, per-library sources

- auth: username lookup is now case-insensitive via func.lower()
- scanner: trigger match_audiobook for each newly found item after scan
- matcher: read match_sources from library settings; refactored to loop
  over configured sources in priority order instead of hardcoded sequence
- schemas/routers: expose matchSources in LibraryOut API response
- Admin UI: pill-toggle for MusicBrainz/Open Library/Google Books per library

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Audiolib
2026-05-26 15:01:56 +02:00
parent b8984f0c2c
commit 6bb07ff873
6 changed files with 104 additions and 57 deletions

View File

@@ -1,5 +1,6 @@
import os
import uuid
import asyncio
import logging
from datetime import datetime
from pathlib import Path
@@ -110,6 +111,7 @@ async def scan_library_task(library_id: str, job_id: str):
all_books.extend(_discover_audiobook_folders(folder_path))
items_found = 0
new_item_ids: list[str] = []
for book_info in all_books:
folder_path = book_info["path"]
audio_files = book_info["files"]
@@ -164,6 +166,8 @@ async def scan_library_task(library_id: str, job_id: str):
)
db.add(bf)
new_item_ids.append(item.id)
items_found += 1
await db.commit()
@@ -187,6 +191,12 @@ async def scan_library_task(library_id: str, job_id: str):
logger.info(f"Scan abgeschlossen: {items_found} Items in Library {library_id}")
# Auto-Matching für neue Items starten
if new_item_ids:
from .matcher import match_audiobook
for iid in new_item_ids:
asyncio.create_task(match_audiobook(iid))
except Exception as e:
logger.error(f"Scan-Fehler für Library {library_id}: {e}", exc_info=True)
async with AsyncSessionLocal() as err_db: