feat: Preserve TV episode NFO filenames matching video files
Local Docker Build (Dev) / build-dev (push) Successful in 29s
Local Docker Build (Dev) / build-dev (push) Successful in 29s
Instead of migrating long NFO names to standardized S01E01.nfo format, now preserves original filenames that match video files while still populating NFOGuard metadata (dateadded, aired, season, episode). Changes: - Added update_episode_nfo_preserving_name() method to NFOManager - Added find_episode_nfo_matching_video() to locate NFO files by video name pattern - Modified TVProcessor to update existing NFOs in-place rather than migrate names - Episodes with existing NFOs now get "nfo_update_required" source for special handling This maintains the user's preferred naming convention where NFO files match their corresponding video files exactly.
This commit is contained in:
+29
-11
@@ -87,13 +87,31 @@ class TVProcessor:
|
||||
# Process episodes
|
||||
for (season, episode), (aired, dateadded, source) in episode_dates.items():
|
||||
if (season, episode) in disk_episodes:
|
||||
# Create NFO
|
||||
# Create or update NFO
|
||||
if config.manage_nfo:
|
||||
season_dir = series_path / config.tv_season_dir_format.format(season=season)
|
||||
self.nfo_manager.create_episode_nfo(
|
||||
season_dir,
|
||||
season, episode, aired, dateadded, source, config.lock_metadata
|
||||
)
|
||||
|
||||
# Check if this is an existing NFO that needs updating while preserving name
|
||||
if source == "nfo_update_required":
|
||||
# Find the existing NFO file and update it in place
|
||||
existing_nfo = self.nfo_manager.find_episode_nfo_matching_video(season_dir, season, episode)
|
||||
if existing_nfo:
|
||||
# Update existing NFO while preserving its filename
|
||||
self.nfo_manager.update_episode_nfo_preserving_name(
|
||||
existing_nfo, season, episode, aired, dateadded, "file_update"
|
||||
)
|
||||
else:
|
||||
# Fallback to standard creation if NFO not found
|
||||
self.nfo_manager.create_episode_nfo(
|
||||
season_dir,
|
||||
season, episode, aired, dateadded, source, config.lock_metadata
|
||||
)
|
||||
else:
|
||||
# Standard NFO creation for new episodes
|
||||
self.nfo_manager.create_episode_nfo(
|
||||
season_dir,
|
||||
season, episode, aired, dateadded, source, config.lock_metadata
|
||||
)
|
||||
|
||||
# Update file mtimes
|
||||
if config.fix_dir_mtimes and dateadded:
|
||||
@@ -170,21 +188,21 @@ class TVProcessor:
|
||||
if key in disk_episodes: # Only use cached data for episodes we have
|
||||
episode_dates[key] = (ep["aired"], ep["dateadded"], ep["source"])
|
||||
|
||||
# Check for existing NFO files (including long-named ones) for migration
|
||||
# Check for existing NFO files that match video file names (preserve long names)
|
||||
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
|
||||
# Check if this episode has an NFO file matching its video file name
|
||||
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)
|
||||
existing_nfo = self.nfo_manager.find_episode_nfo_matching_video(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")
|
||||
# Force processing of this episode to update NFO with NFOGuard data
|
||||
episode_dates[(season_num, episode_num)] = (None, None, "nfo_update_required")
|
||||
nfo_episodes_found += 1
|
||||
|
||||
if nfo_episodes_found > 0:
|
||||
_log("INFO", f"Found {nfo_episodes_found} episodes with existing NFO files requiring migration")
|
||||
_log("INFO", f"Found {nfo_episodes_found} episodes with existing NFO files to update (preserving names)")
|
||||
|
||||
# Find missing episodes (not in cache and no existing NFO)
|
||||
cached_keys = set(episode_dates.keys())
|
||||
|
||||
Reference in New Issue
Block a user