dev #66
+62
-36
@@ -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
|
||||
try:
|
||||
nfo_manager = dependencies.get("nfo_manager")
|
||||
if nfo_manager and result.get('video_path'):
|
||||
video_path = result['video_path']
|
||||
print(f"DEBUG: Auto-fixing NFO for episode {imdb_id} S{season:02d}E{episode:02d} at {video_path}")
|
||||
config = dependencies.get("config")
|
||||
if nfo_manager and config:
|
||||
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
|
||||
video_file = Path(video_path)
|
||||
if video_file.exists():
|
||||
# Use NFO manager to update the episode NFO file
|
||||
nfo_manager.create_episode_nfo(
|
||||
video_file.parent,
|
||||
season,
|
||||
episode,
|
||||
imdb_id,
|
||||
dateadded,
|
||||
result.get('air_date'),
|
||||
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}")
|
||||
tv_library_path = Path(config.tv_library_path)
|
||||
|
||||
# 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
|
||||
nfo_manager.create_episode_nfo(
|
||||
season_dir,
|
||||
season,
|
||||
episode,
|
||||
imdb_id,
|
||||
dateadded,
|
||||
result.get('aired'),
|
||||
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}")
|
||||
else:
|
||||
print(f"WARNING: Season directory not found: {season_dir}")
|
||||
else:
|
||||
print(f"WARNING: Video file not found for auto-fix: {video_path}")
|
||||
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}, video_path: {result.get('video_path', 'None')}")
|
||||
print(f"DEBUG: Auto-fix skipped - nfo_manager: {nfo_manager is not None}, config: {config is not None}")
|
||||
except Exception as 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
|
||||
@@ -2350,27 +2364,39 @@ async def lookup_movie(imdb_id: str, dependencies: dict):
|
||||
# AUTO-FIX: Update NFO file with missing dateadded element
|
||||
try:
|
||||
nfo_manager = dependencies.get("nfo_manager")
|
||||
if nfo_manager and result.get('video_path'):
|
||||
video_path = result['video_path']
|
||||
print(f"DEBUG: Auto-fixing NFO for movie {imdb_id} at {video_path}")
|
||||
config = dependencies.get("config")
|
||||
if nfo_manager and config:
|
||||
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
|
||||
video_file = Path(video_path)
|
||||
if video_file.exists():
|
||||
# Use NFO manager to update the movie NFO file
|
||||
nfo_manager.create_movie_nfo(
|
||||
video_file.parent,
|
||||
imdb_id,
|
||||
dateadded,
|
||||
result.get('released'),
|
||||
source=f"NFOGuard auto-fix via Emby lookup - {result.get('source', 'database')}"
|
||||
)
|
||||
print(f"SUCCESS: Auto-fixed NFO file for movie {imdb_id}")
|
||||
movie_library_path = Path(config.movie_library_path)
|
||||
|
||||
# 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
|
||||
nfo_manager.create_movie_nfo(
|
||||
movie_dir,
|
||||
imdb_id,
|
||||
dateadded,
|
||||
result.get('released'),
|
||||
source=f"NFOGuard auto-fix via Emby lookup - {result.get('source', 'database')}"
|
||||
)
|
||||
print(f"SUCCESS: Auto-fixed NFO file for movie {imdb_id}")
|
||||
else:
|
||||
print(f"WARNING: Movie directory not found: {movie_dir}")
|
||||
else:
|
||||
print(f"WARNING: Video file not found for auto-fix: {video_path}")
|
||||
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}, video_path: {result.get('video_path', 'None')}")
|
||||
print(f"DEBUG: Auto-fix skipped - nfo_manager: {nfo_manager is not None}, config: {config is not None}")
|
||||
except Exception as fix_error:
|
||||
print(f"WARNING: Auto-fix failed for movie {imdb_id}: {fix_error}")
|
||||
# Don't fail the lookup if auto-fix fails
|
||||
|
||||
Reference in New Issue
Block a user