fix: nfo
Local Docker Build (Dev) / build-dev (pull_request) Successful in 23s

This commit is contained in:
2025-09-24 19:35:39 -04:00
parent 210af8ac4b
commit 27430a7ead
2 changed files with 19 additions and 44 deletions
-42
View File
@@ -685,45 +685,3 @@ class NFOManager:
else: else:
print(f"⚠️ No video files found to update in {movie_dir.name}") print(f"⚠️ No video files found to update in {movie_dir.name}")
def find_existing_episode_nfo(self, season_dir: Path, season_num: int, episode_num: int) -> Optional[Path]:
"""Find existing episode NFO file that matches season/episode but isn't standardized name"""
if not season_dir.exists():
return None
# Standard filename pattern we're looking to create
standard_pattern = f"S{season_num:02d}E{episode_num:02d}.nfo"
# Look for NFO files in the season directory
for nfo_file in season_dir.glob("*.nfo"):
# Skip if it's already the standard format
if nfo_file.name == standard_pattern:
continue
# Check if this NFO contains the right season/episode
try:
tree = ET.parse(nfo_file)
root = tree.getroot()
if root.tag == "episodedetails":
# Check for season/episode elements
season_elem = root.find("season")
episode_elem = root.find("episode")
if season_elem is not None and episode_elem is not None:
try:
file_season = int(season_elem.text)
file_episode = int(episode_elem.text)
# If this NFO matches our target season/episode, return it
if file_season == season_num and file_episode == episode_num:
print(f"🔍 Found existing long-named NFO for S{season_num:02d}E{episode_num:02d}: {nfo_file.name}")
return nfo_file
except (ValueError, TypeError):
# Skip NFO files with invalid season/episode numbers
continue
except ET.ParseError:
# Skip malformed NFO files
continue
return None
+19 -2
View File
@@ -440,12 +440,29 @@ class TVProcessor:
if key in disk_episodes: # Only use cached data for episodes we have if key in disk_episodes: # Only use cached data for episodes we have
episode_dates[key] = (ep["aired"], ep["dateadded"], ep["source"]) 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()) cached_keys = set(episode_dates.keys())
missing_keys = set(disk_episodes.keys()) - cached_keys missing_keys = set(disk_episodes.keys()) - cached_keys
if not missing_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 return episode_dates
_log("INFO", f"Querying APIs for {len(missing_keys)} missing episodes") _log("INFO", f"Querying APIs for {len(missing_keys)} missing episodes")