From a559873999559b36661ccd8195a4a623c5f5d621 Mon Sep 17 00:00:00 2001 From: sbcrumb Date: Sun, 12 Oct 2025 11:15:20 -0400 Subject: [PATCH] release: Clean up debug logging and bump to v2.1.0 FEATURES ADDED: - Comprehensive TV IMDb detection (folder/filename/NFO) - TV show batch validation prevents wrong series processing - Fixed glob pattern for exact IMDb matching - Enhanced webhook path mapping reliability CLEANUP: - Removed temporary debug print statements - Clean production-ready logging - Maintains all core improvements from debugging session FIXES: - Resolves Girls (2012) vs Golden Girls matching issue - Proper bracket escaping in glob patterns - Comprehensive IMDb detection for both movies and TV shows --- VERSION | 2 +- core/nfo_manager.py | 18 ------------------ utils/file_utils.py | 28 ---------------------------- 3 files changed, 1 insertion(+), 47 deletions(-) diff --git a/VERSION b/VERSION index 0047786..7ec1d6d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.0.28 +2.1.0 diff --git a/core/nfo_manager.py b/core/nfo_manager.py index d387c5a..da297dd 100644 --- a/core/nfo_manager.py +++ b/core/nfo_manager.py @@ -97,12 +97,9 @@ 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 @@ -110,30 +107,21 @@ 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 (including TMDB fallback) nfo_path = movie_dir / "movie.nfo" imdb_id = self.parse_imdb_from_nfo(nfo_path) if imdb_id: - if imdb_id.startswith("tmdb-"): - print(f"✅ Found TMDB ID in NFO file: {imdb_id} from {nfo_path} (fallback mode)") - else: - print(f"✅ Found IMDb ID in NFO file: {imdb_id} from {nfo_path}") return imdb_id - print(f"❌ No IMDb or TMDB ID found in directory, filenames, or NFO for: {movie_dir.name}") return None def find_series_imdb_id(self, series_dir: Path) -> Optional[str]: """Find IMDb ID from TV series directory name, filenames, or tvshow.nfo file""" - print(f"🔍 Searching for IMDb ID in TV series: {series_dir.name}") - # First try directory name imdb_id = self.parse_imdb_from_path(series_dir) if imdb_id: - print(f"✅ Found IMDb ID in series directory name: {imdb_id}") return imdb_id # Try all files in the directory for IMDb ID patterns @@ -141,20 +129,14 @@ 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 series filename: {imdb_id} from {file_path.name}") return imdb_id # Finally, try tvshow.nfo file content nfo_path = series_dir / "tvshow.nfo" imdb_id = self.parse_imdb_from_nfo(nfo_path) if imdb_id: - if imdb_id.startswith("tmdb-"): - print(f"✅ Found TMDB ID in tvshow.nfo: {imdb_id} from {nfo_path} (fallback mode)") - else: - print(f"✅ Found IMDb ID in tvshow.nfo: {imdb_id} from {nfo_path}") return imdb_id - print(f"❌ No IMDb or TMDB ID found in series directory, filenames, or tvshow.nfo for: {series_dir.name}") return None def extract_nfoguard_dates_from_nfo(self, nfo_path: Path) -> Optional[Dict[str, str]]: diff --git a/utils/file_utils.py b/utils/file_utils.py index 20e0e79..8bce466 100644 --- a/utils/file_utils.py +++ b/utils/file_utils.py @@ -40,69 +40,41 @@ def find_media_path_by_imdb_and_title( Path to media directory if found, None otherwise """ # Try webhook path first if provided - print(f"🔍 Webhook path provided: {webhook_path}") - print(f"🔍 Path mapper available: {path_mapper is not None}") if webhook_path and path_mapper: try: if hasattr(path_mapper, 'sonarr_path_to_container_path'): - # Force debug mode for path mapping - old_debug = getattr(path_mapper, 'path_debug', False) - path_mapper.path_debug = True container_path = path_mapper.sonarr_path_to_container_path(webhook_path) - path_mapper.path_debug = old_debug - print(f"🔍 Sonarr path mapped: {webhook_path} → {container_path}") elif hasattr(path_mapper, 'radarr_path_to_container_path'): container_path = path_mapper.radarr_path_to_container_path(webhook_path) - print(f"🔍 Radarr path mapped: {webhook_path} → {container_path}") else: container_path = webhook_path - print(f"🔍 No mapper, using direct path: {container_path}") path_obj = Path(container_path) - print(f"🔍 Mapped path exists: {path_obj.exists()} - {path_obj}") if path_obj.exists(): - print(f"✅ Using webhook path: {path_obj}") return path_obj - else: - print(f"❌ Webhook path doesn't exist, falling back to search") except Exception as e: - print(f"❌ Failed to process webhook path {webhook_path}: {e}") _log("WARNING", f"Failed to process webhook path {webhook_path}: {e}") - else: - if not webhook_path: - print(f"❌ No webhook path provided") - if not path_mapper: - print(f"❌ No path mapper available") # Search by IMDb ID or title in configured paths - print(f"🔍 Total search paths to check: {len(search_paths)} - {[str(p) for p in search_paths]}") for media_path in search_paths: - print(f"🔍 Checking path: {media_path} (exists: {media_path.exists()})") if not media_path.exists(): - print(f"❌ Skipping non-existent path: {media_path}") continue # Search by IMDb ID first (more reliable) if imdb_id: # Use proper glob pattern - escape brackets to match literal [imdb-ID] pattern = str(media_path / f"*\\[imdb-{imdb_id}\\]*") - print(f"🔍 Searching with pattern: {pattern}") matches = glob.glob(pattern) - print(f"🔍 Pattern matches found: {len(matches)} - {matches[:3] if matches else 'None'}") if matches: - print(f"✅ Returning first match: {matches[0]}") return Path(matches[0]) # Search by title as fallback if title: title_clean = clean_title_for_search(title) - print(f"🔍 Title fallback: searching for '{title}' → cleaned: '{title_clean}'") for item in media_path.iterdir(): if item.is_dir() and "[imdb-" in item.name.lower(): item_clean = clean_title_for_search(item.name) - print(f"🔍 Checking directory: '{item.name}' → cleaned: '{item_clean}'") if title_clean in item_clean: - print(f"✅ Title match found: '{title_clean}' in '{item_clean}' → returning {item}") return item return None