From edaa92ef9aec8348d906d551b80cc882283ba5f1 Mon Sep 17 00:00:00 2001 From: sbcrumb Date: Wed, 24 Sep 2025 20:06:45 -0400 Subject: [PATCH] dev (#6) Reviewed-on: https://gitea.skalas.org/sbcrumb/nfoguard/pulls/6 --- core/nfo_manager.py | 3 ++- nfoguard.py | 22 ++++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/core/nfo_manager.py b/core/nfo_manager.py index fbc1005..09c4e29 100644 --- a/core/nfo_manager.py +++ b/core/nfo_manager.py @@ -683,4 +683,5 @@ class NFOManager: if updated_files: print(f"✅ Updated {len(updated_files)} video file timestamps in {movie_dir.name}") else: - print(f"⚠️ No video files found to update in {movie_dir.name}") \ No newline at end of file + print(f"⚠️ No video files found to update in {movie_dir.name}") + diff --git a/nfoguard.py b/nfoguard.py index 223d4d1..2584c97 100644 --- a/nfoguard.py +++ b/nfoguard.py @@ -440,12 +440,29 @@ class TVProcessor: if key in disk_episodes: # Only use cached data for episodes we have episode_dates[key] = (ep["aired"], ep["dateadded"], ep["source"]) - # Find missing episodes + # Check for existing NFO files (including long-named ones) for migration + nfo_episodes_found = 0 + for (season_num, episode_num) in disk_episodes.keys(): + if (season_num, episode_num) not in episode_dates: + # Check if this episode has an existing NFO file that needs migration + season_dir = series_path / config.tv_season_dir_format.format(season=season_num) + existing_nfo = self.nfo_manager.find_existing_episode_nfo(season_dir, season_num, episode_num) + + if existing_nfo: + # Force processing of this episode for NFO migration + episode_dates[(season_num, episode_num)] = (None, None, "nfo_migration_required") + nfo_episodes_found += 1 + + if nfo_episodes_found > 0: + _log("INFO", f"Found {nfo_episodes_found} episodes with existing NFO files requiring migration") + + # Find missing episodes (not in cache and no existing NFO) cached_keys = set(episode_dates.keys()) missing_keys = set(disk_episodes.keys()) - cached_keys if not missing_keys: - _log("INFO", "All episodes found in cache") + if nfo_episodes_found == 0: + _log("INFO", "All episodes found in cache") return episode_dates _log("INFO", f"Querying APIs for {len(missing_keys)} missing episodes") @@ -697,6 +714,7 @@ class TVProcessor: return None + def _get_sonarr_series_metadata(self, imdb_id: str) -> Optional[Dict[str, Any]]: """Get enhanced series metadata from Sonarr API""" try: