feat: implement NFO ID storage and media scan tracking
Task 3 (NFO data): - Add parse_nfo_ids() method to NFOService - Extract TMDB/TVDB IDs from NFO files during scan - Update database with extracted IDs - Add comprehensive unit and integration tests Task 4 (Media scan): - Track initial media scan with SystemSettings flag - Run background loading only on first startup - Skip media scan on subsequent runs
This commit is contained in:
@@ -341,8 +341,52 @@ async def lifespan(_application: FastAPI):
|
||||
await background_loader.start()
|
||||
logger.info("Background loader service started")
|
||||
|
||||
# Check for incomplete series and queue background loading
|
||||
await _check_incomplete_series_on_startup(background_loader)
|
||||
# Check if initial media scan has been completed
|
||||
is_media_scan_done = False
|
||||
try:
|
||||
async with get_db_session() as db:
|
||||
is_media_scan_done = (
|
||||
await SystemSettingsService
|
||||
.is_initial_media_scan_completed(db)
|
||||
)
|
||||
except Exception as e:
|
||||
logger.warning(
|
||||
"Failed to check media scan status: %s, assuming not done",
|
||||
e
|
||||
)
|
||||
is_media_scan_done = False
|
||||
|
||||
# Run media scan only on first run
|
||||
if not is_media_scan_done:
|
||||
logger.info("Performing initial media scan...")
|
||||
try:
|
||||
# Check for incomplete series and queue background loading
|
||||
await _check_incomplete_series_on_startup(background_loader)
|
||||
logger.info("Initial media scan completed")
|
||||
|
||||
# Mark media scan as completed
|
||||
try:
|
||||
async with get_db_session() as db:
|
||||
await (
|
||||
SystemSettingsService
|
||||
.mark_initial_media_scan_completed(db)
|
||||
)
|
||||
logger.info("Marked media scan as completed")
|
||||
except Exception as e:
|
||||
logger.warning(
|
||||
"Failed to mark media scan as completed: %s",
|
||||
e
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(
|
||||
"Failed to complete media scan: %s",
|
||||
e,
|
||||
exc_info=True
|
||||
)
|
||||
else:
|
||||
logger.info(
|
||||
"Skipping media scan - already completed on previous run"
|
||||
)
|
||||
else:
|
||||
logger.info(
|
||||
"Download service initialization skipped - "
|
||||
|
||||
Reference in New Issue
Block a user