From b9e3ae3a5e8ffa98a60d14b452cae3b9f85be7ea Mon Sep 17 00:00:00 2001 From: SBCrumb Date: Fri, 26 Sep 2025 14:37:41 -0400 Subject: [PATCH] debug: Add extensive logging for episode detection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added detailed debug logging to diagnose why High Potential shows "0 episodes" despite having video files: - Log season directory detection and pattern matching - Log video file scanning and episode filename parsing - Log season number extraction and matching logic - Log final episode count and processing decisions This will help identify where the episode detection is failing in the pipeline. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- VERSION | 2 +- core/episode_nfo_manager.py | 6 ++++++ processors/tv_series_processor.py | 9 +++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 90648db..9b4bfb7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.0.5-sonarr-direct-lookup +2.0.6-debug-episode-detection diff --git a/core/episode_nfo_manager.py b/core/episode_nfo_manager.py index 39acfc7..b6823d4 100644 --- a/core/episode_nfo_manager.py +++ b/core/episode_nfo_manager.py @@ -19,23 +19,29 @@ class EpisodeNFOManager: def find_video_files_for_season(self, season_dir: Path) -> Dict[Tuple[int, int], List[Path]]: """Find all video files in season directory, grouped by (season, episode)""" if not season_dir.exists(): + _log("DEBUG", f"Season directory does not exist: {season_dir}") return {} video_extensions = [".mkv", ".mp4", ".avi", ".mov", ".m4v"] episodes = {} + _log("DEBUG", f"Scanning video files in: {season_dir}") for video_file in season_dir.iterdir(): + _log("DEBUG", f"Checking file: {video_file.name} (is_file: {video_file.is_file()}, suffix: {video_file.suffix.lower()})") if (video_file.is_file() and video_file.suffix.lower() in video_extensions): episode_info = self._parse_episode_from_filename(video_file.name) + _log("DEBUG", f"Episode parsing for '{video_file.name}': {episode_info}") if episode_info: season_num, episode_num = episode_info key = (season_num, episode_num) if key not in episodes: episodes[key] = [] episodes[key].append(video_file) + _log("DEBUG", f"Added video file: S{season_num:02d}E{episode_num:02d} → {video_file.name}") + _log("DEBUG", f"Total video files found: {len(episodes)} episodes") return episodes def _parse_episode_from_filename(self, filename: str) -> Optional[Tuple[int, int]]: diff --git a/processors/tv_series_processor.py b/processors/tv_series_processor.py index 18110f3..fb67991 100644 --- a/processors/tv_series_processor.py +++ b/processors/tv_series_processor.py @@ -98,20 +98,29 @@ class TVSeriesProcessor: """Find all episodes on disk, grouped by (season, episode)""" episodes = {} + _log("DEBUG", f"Scanning for season directories in: {series_path}") for season_dir in series_path.iterdir(): + _log("DEBUG", f"Checking directory: {season_dir.name} (is_dir: {season_dir.is_dir()})") if season_dir.is_dir() and self._is_season_directory(season_dir.name): season_num = self._extract_season_number(season_dir.name) + _log("DEBUG", f"Found season directory: {season_dir.name} → season {season_num}") if season_num is None: continue # Find video files in this season season_episodes = self.episode_nfo_manager.find_video_files_for_season(season_dir) + _log("DEBUG", f"Found {len(season_episodes)} episodes in {season_dir.name}: {list(season_episodes.keys())}") # Add season directory info to episodes for (s_num, e_num), video_files in season_episodes.items(): + _log("DEBUG", f"Episode S{s_num:02d}E{e_num:02d}: season_dir={season_num}, filename_season={s_num}") if s_num == season_num: # Verify season matches directory episodes[(s_num, e_num)] = video_files + _log("DEBUG", f"Added episode S{s_num:02d}E{e_num:02d} to processing list") + else: + _log("WARNING", f"Season mismatch: directory={season_num}, filename={s_num} for S{s_num:02d}E{e_num:02d}") + _log("DEBUG", f"Total episodes found on disk: {len(episodes)}") return episodes def _extract_season_number(self, dirname: str) -> Optional[int]: