debug: Add IMDb ID detection logging and database-first optimization
Local Docker Build (Dev) / build-dev (push) Successful in 18s

Added comprehensive debugging for IMDb ID detection to identify issues
with directories that don't have IMDb IDs in folder names but do have
them in filenames (like Adulthood (2025) [tt26657977]).

Also added database-first optimization that skips expensive API calls
when we already have complete data in the database. This should:
- Speed up full rescans significantly
- Reduce unnecessary API calls to TMDB/OMDB/Radarr
- Keep database size appropriate by not re-querying known movies

This should resolve both the small database size issue and improve
performance for movies that already have valid dateadded entries.
This commit is contained in:
2025-09-24 11:16:56 -04:00
parent ed03f23272
commit 172a364e6e
2 changed files with 25 additions and 1 deletions
+19
View File
@@ -974,6 +974,25 @@ class MovieProcessor:
existing = self.db.get_movie_dates(imdb_id)
_log("DEBUG", f"Database lookup for {imdb_id}: {existing}")
# If we have complete data in database, use it and skip expensive API calls
if existing and existing.get("dateadded") and existing.get("source") != "no_valid_date_source":
_log("INFO", f"✅ Using complete database data for {imdb_id}: {existing['dateadded']} (source: {existing['source']})")
# Still create NFO and update files but skip API queries
dateadded, source, released = existing["dateadded"], existing["source"], existing.get("released")
# Create NFO with existing data
if config.manage_nfo:
self.nfo_manager.create_movie_nfo(
movie_path, imdb_id, dateadded, released, source, config.lock_metadata
)
# Update file mtimes if enabled
if config.fix_dir_mtimes and dateadded:
self.nfo_manager.update_movie_files_mtime(movie_path, dateadded)
_log("INFO", f"Completed processing movie: {movie_path.name} (source: {source}) [database-only]")
return
# Handle webhook mode - prioritize database, then use proper date logic
if webhook_mode:
_log("DEBUG", f"Webhook mode: existing={bool(existing)}, has_dateadded={bool(existing and existing.get('dateadded')) if existing else 'N/A'}")