diff --git a/core/nfo_manager.py b/core/nfo_manager.py index fbaf6f9..a632fd5 100644 --- a/core/nfo_manager.py +++ b/core/nfo_manager.py @@ -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): diff --git a/nfoguard.py b/nfoguard.py index 74b0b85..16369a9 100644 --- a/nfoguard.py +++ b/nfoguard.py @@ -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'}")