feat: Complete elimination of short NFO names - always match video filenames
Local Docker Build (Dev) / build-dev (push) Successful in 33s

- Added logic to actively delete existing S01E01.nfo short-name files
- Modified fallback creation to always match video file names
- Added find_video_file_for_episode() to locate matching video files
- NFO files will now ALWAYS have the same name as their video files
- No more S01E01.nfo format ever created, addressing Emby compatibility issues

This ensures complete consistency between NFO and video file naming,
which should resolve Emby metadata reading issues.
This commit is contained in:
2025-09-26 08:35:54 -04:00
parent b63c188813
commit 5810877489
2 changed files with 41 additions and 5 deletions
+1 -1
View File
@@ -1 +1 @@
1.9.3 1.9.4
+38 -2
View File
@@ -650,11 +650,29 @@ class NFOManager:
else: else:
print(f"⚠️ Failed to update existing NFO, falling back to standard creation") print(f"⚠️ Failed to update existing NFO, falling back to standard creation")
# Fallback: Create standard S01E01.nfo format (for new episodes without existing NFOs) # Check for and remove old short-name NFO files (S01E01.nfo format)
short_nfo_path = season_dir / f"S{season_num:02d}E{episode_num:02d}.nfo"
if short_nfo_path.exists():
print(f"🗑️ Removing old short-name NFO: {short_nfo_path.name}")
try:
short_nfo_path.unlink()
print(f"✅ Deleted short-name NFO file: {short_nfo_path.name}")
except Exception as e:
print(f"⚠️ Warning: Could not delete short-name NFO {short_nfo_path.name}: {e}")
# Fallback: Create NFO file matching video file name (no more short S01E01.nfo names)
video_file = self.find_video_file_for_episode(season_dir, season_num, episode_num)
if video_file:
# Create NFO with same name as video file
nfo_path = video_file.with_suffix('.nfo')
print(f"🎬 Creating new NFO matching video file: {nfo_path.name}")
else:
# Last resort: create with season/episode pattern (but this should rarely happen)
episode_filename = f"S{season_num:02d}E{episode_num:02d}.nfo" episode_filename = f"S{season_num:02d}E{episode_num:02d}.nfo"
nfo_path = season_dir / episode_filename nfo_path = season_dir / episode_filename
print(f"⚠️ No video file found, creating basic NFO: {episode_filename}")
# Check if standard format NFO exists # Check if NFO already exists
source_nfo_path = nfo_path if nfo_path.exists() else None source_nfo_path = nfo_path if nfo_path.exists() else None
if source_nfo_path: if source_nfo_path:
@@ -1035,3 +1053,21 @@ class NFOManager:
return None return None
def find_video_file_for_episode(self, season_dir: Path, season_num: int, episode_num: int) -> Optional[Path]:
"""Find the video file for a specific episode to match NFO naming"""
if not season_dir.exists():
return None
# Find video files for this episode (check common patterns)
season_episode_pattern = f"S{season_num:02d}E{episode_num:02d}"
# Look for video files with season/episode pattern
video_extensions = ['.mkv', '.mp4', '.avi', '.m4v']
for ext in video_extensions:
video_files = list(season_dir.glob(f"*{season_episode_pattern}*{ext}"))
if video_files:
# Return the first matching video file
return video_files[0]
return None