update autfix
Local Docker Build (Dev) / build-dev (push) Successful in 5s

This commit is contained in:
2025-10-28 20:07:08 -04:00
parent 614dab632a
commit 7f0ad27009
+45 -19
View File
@@ -2264,29 +2264,43 @@ async def lookup_episode(imdb_id: str, season: int, episode: int, dependencies:
# AUTO-FIX: Update NFO file with missing dateadded element # AUTO-FIX: Update NFO file with missing dateadded element
try: try:
nfo_manager = dependencies.get("nfo_manager") nfo_manager = dependencies.get("nfo_manager")
if nfo_manager and result.get('video_path'): config = dependencies.get("config")
video_path = result['video_path'] if nfo_manager and config:
print(f"DEBUG: Auto-fixing NFO for episode {imdb_id} S{season:02d}E{episode:02d} at {video_path}") print(f"DEBUG: Auto-fixing NFO for episode {imdb_id} S{season:02d}E{episode:02d}")
# Create NFO with dateadded element # Find the series directory using the same logic NFOGuard uses
from pathlib import Path from pathlib import Path
video_file = Path(video_path) tv_library_path = Path(config.tv_library_path)
if video_file.exists():
# Look for series directory with IMDb ID pattern
import glob
pattern = f"*[imdb-{imdb_id}]*"
series_matches = list(tv_library_path.glob(f"**/{pattern}"))
if series_matches:
series_dir = series_matches[0] # Take first match
season_dir = series_dir / config.get_season_dir_name(season)
if season_dir.exists():
print(f"DEBUG: Found season directory: {season_dir}")
# Use NFO manager to update the episode NFO file # Use NFO manager to update the episode NFO file
nfo_manager.create_episode_nfo( nfo_manager.create_episode_nfo(
video_file.parent, season_dir,
season, season,
episode, episode,
imdb_id, imdb_id,
dateadded, dateadded,
result.get('air_date'), result.get('aired'),
source=f"NFOGuard auto-fix via Emby lookup - {result.get('source', 'database')}" source=f"NFOGuard auto-fix via Emby lookup - {result.get('source', 'database')}"
) )
print(f"SUCCESS: Auto-fixed NFO file for {imdb_id} S{season:02d}E{episode:02d}") print(f"SUCCESS: Auto-fixed NFO file for {imdb_id} S{season:02d}E{episode:02d}")
else: else:
print(f"WARNING: Video file not found for auto-fix: {video_path}") print(f"WARNING: Season directory not found: {season_dir}")
else: else:
print(f"DEBUG: Auto-fix skipped - nfo_manager: {nfo_manager is not None}, video_path: {result.get('video_path', 'None')}") print(f"WARNING: Series directory not found for {imdb_id} in {tv_library_path}")
else:
print(f"DEBUG: Auto-fix skipped - nfo_manager: {nfo_manager is not None}, config: {config is not None}")
except Exception as fix_error: except Exception as fix_error:
print(f"WARNING: Auto-fix failed for {imdb_id} S{season:02d}E{episode:02d}: {fix_error}") print(f"WARNING: Auto-fix failed for {imdb_id} S{season:02d}E{episode:02d}: {fix_error}")
# Don't fail the lookup if auto-fix fails # Don't fail the lookup if auto-fix fails
@@ -2350,17 +2364,27 @@ async def lookup_movie(imdb_id: str, dependencies: dict):
# AUTO-FIX: Update NFO file with missing dateadded element # AUTO-FIX: Update NFO file with missing dateadded element
try: try:
nfo_manager = dependencies.get("nfo_manager") nfo_manager = dependencies.get("nfo_manager")
if nfo_manager and result.get('video_path'): config = dependencies.get("config")
video_path = result['video_path'] if nfo_manager and config:
print(f"DEBUG: Auto-fixing NFO for movie {imdb_id} at {video_path}") print(f"DEBUG: Auto-fixing NFO for movie {imdb_id}")
# Create NFO with dateadded element # Find the movie directory using the same logic NFOGuard uses
from pathlib import Path from pathlib import Path
video_file = Path(video_path) movie_library_path = Path(config.movie_library_path)
if video_file.exists():
# Look for movie directory with IMDb ID pattern
pattern = f"*[imdb-{imdb_id}]*"
movie_matches = list(movie_library_path.glob(f"**/{pattern}"))
if movie_matches:
movie_dir = movie_matches[0] # Take first match
if movie_dir.exists():
print(f"DEBUG: Found movie directory: {movie_dir}")
# Use NFO manager to update the movie NFO file # Use NFO manager to update the movie NFO file
nfo_manager.create_movie_nfo( nfo_manager.create_movie_nfo(
video_file.parent, movie_dir,
imdb_id, imdb_id,
dateadded, dateadded,
result.get('released'), result.get('released'),
@@ -2368,9 +2392,11 @@ async def lookup_movie(imdb_id: str, dependencies: dict):
) )
print(f"SUCCESS: Auto-fixed NFO file for movie {imdb_id}") print(f"SUCCESS: Auto-fixed NFO file for movie {imdb_id}")
else: else:
print(f"WARNING: Video file not found for auto-fix: {video_path}") print(f"WARNING: Movie directory not found: {movie_dir}")
else: else:
print(f"DEBUG: Auto-fix skipped - nfo_manager: {nfo_manager is not None}, video_path: {result.get('video_path', 'None')}") print(f"WARNING: Movie directory not found for {imdb_id} in {movie_library_path}")
else:
print(f"DEBUG: Auto-fix skipped - nfo_manager: {nfo_manager is not None}, config: {config is not None}")
except Exception as fix_error: except Exception as fix_error:
print(f"WARNING: Auto-fix failed for movie {imdb_id}: {fix_error}") print(f"WARNING: Auto-fix failed for movie {imdb_id}: {fix_error}")
# Don't fail the lookup if auto-fix fails # Don't fail the lookup if auto-fix fails