fix: External API fallback flow and conditional NFO creation
Local Docker Build (Dev) / build-dev (push) Successful in 23s

Fixed two critical issues:
1. External API fallback was never reached because early returns when series/episodes not found in Sonarr
2. tvshow.nfo and season.nfo were always created even if they already existed

Changes:
- Restructured Sonarr lookup to fall through to external APIs when series/episodes not found
- Made tvshow.nfo and season.nfo creation conditional (only if files don't exist)
- Added debug logging for skipped NFO creation
- Version bump to 2.0.4-fallback-fix

Now series like High Potential should properly fall back to TMDB/OMDb for episode airdates.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-26 14:12:18 -04:00
parent 2e6d8a35e7
commit 27677e49f8
2 changed files with 50 additions and 41 deletions
+1 -1
View File
@@ -1 +1 @@
2.0.3-external-fallback 2.0.4-fallback-fix
+16 -7
View File
@@ -191,8 +191,9 @@ class TVSeriesProcessor:
series = self.sonarr.series_by_imdb(imdb_id) series = self.sonarr.series_by_imdb(imdb_id)
if not series: if not series:
_log("WARNING", f"Series not found in Sonarr for IMDb: {imdb_id}") _log("WARNING", f"Series not found in Sonarr for IMDb: {imdb_id}")
return aired, dateadded, source # Don't return here - fall through to external API fallback
pass
else:
# Get episodes for series # Get episodes for series
episodes = self.sonarr.episodes_for_series(series["id"]) episodes = self.sonarr.episodes_for_series(series["id"])
target_episode = None target_episode = None
@@ -205,8 +206,8 @@ class TVSeriesProcessor:
if not target_episode: if not target_episode:
_log("WARNING", f"Episode S{season_num:02d}E{episode_num:02d} not found in Sonarr") _log("WARNING", f"Episode S{season_num:02d}E{episode_num:02d} not found in Sonarr")
return aired, dateadded, source # Don't return here - fall through to external API fallback
else:
# Get airdate # Get airdate
aired = target_episode.get("airDateUtc") aired = target_episode.get("airDateUtc")
@@ -317,13 +318,21 @@ class TVSeriesProcessor:
return None, "no_external_data" return None, "no_external_data"
def _create_series_nfos(self, series_path: Path, imdb_id: str): def _create_series_nfos(self, series_path: Path, imdb_id: str):
"""Create tvshow.nfo and season.nfo files""" """Create tvshow.nfo and season.nfo files only if they don't exist"""
# Create tvshow.nfo # Create tvshow.nfo only if it doesn't exist
tvshow_nfo = series_path / "tvshow.nfo"
if not tvshow_nfo.exists():
self.nfo_manager.create_tvshow_nfo(series_path, imdb_id) self.nfo_manager.create_tvshow_nfo(series_path, imdb_id)
else:
_log("DEBUG", f"Skipping tvshow.nfo creation - already exists: {tvshow_nfo}")
# Create season.nfo for each season directory # Create season.nfo for each season directory only if they don't exist
for season_dir in series_path.iterdir(): for season_dir in series_path.iterdir():
if season_dir.is_dir() and self._is_season_directory(season_dir.name): if season_dir.is_dir() and self._is_season_directory(season_dir.name):
season_num = self._extract_season_number(season_dir.name) season_num = self._extract_season_number(season_dir.name)
if season_num is not None: if season_num is not None:
season_nfo = season_dir / "season.nfo"
if not season_nfo.exists():
self.nfo_manager.create_season_nfo(season_dir, season_num) self.nfo_manager.create_season_nfo(season_dir, season_num)
else:
_log("DEBUG", f"Skipping season.nfo creation - already exists: {season_nfo}")