debug: Add IMDb ID detection logging and database-first optimization
Local Docker Build (Dev) / build-dev (push) Successful in 18s
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:
+6
-1
@@ -88,9 +88,12 @@ class NFOManager:
|
||||
|
||||
def find_movie_imdb_id(self, movie_dir: Path) -> Optional[str]:
|
||||
"""Find IMDb ID from directory name, filenames, or NFO file"""
|
||||
print(f"🔍 Searching for IMDb ID in: {movie_dir.name}")
|
||||
|
||||
# First try directory name
|
||||
imdb_id = self.parse_imdb_from_path(movie_dir)
|
||||
if imdb_id:
|
||||
print(f"✅ Found IMDb ID in directory name: {imdb_id}")
|
||||
return imdb_id
|
||||
|
||||
# Try all files in the directory for IMDb ID patterns
|
||||
@@ -98,15 +101,17 @@ class NFOManager:
|
||||
if file_path.is_file():
|
||||
imdb_id = self.parse_imdb_from_path(file_path)
|
||||
if imdb_id:
|
||||
print(f"✅ Found IMDb ID in filename: {imdb_id} from {file_path.name}")
|
||||
return imdb_id
|
||||
|
||||
# Finally, try NFO file content
|
||||
nfo_path = movie_dir / "movie.nfo"
|
||||
imdb_id = self.parse_imdb_from_nfo(nfo_path)
|
||||
if imdb_id:
|
||||
print(f"🔍 Found IMDb ID in NFO file: {imdb_id} from {nfo_path}")
|
||||
print(f"✅ Found IMDb ID in NFO file: {imdb_id} from {nfo_path}")
|
||||
return imdb_id
|
||||
|
||||
print(f"❌ No IMDb ID found in directory, filenames, or NFO for: {movie_dir.name}")
|
||||
return None
|
||||
|
||||
def _parse_nfo_with_tolerance(self, nfo_path: Path):
|
||||
|
||||
+19
@@ -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'}")
|
||||
|
||||
Reference in New Issue
Block a user