From 7bab45a9aa447324293a6adf5564087bac8302af Mon Sep 17 00:00:00 2001 From: SBCrumb Date: Tue, 28 Oct 2025 20:09:55 -0400 Subject: [PATCH] autfix update --- api/routes.py | 45 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/api/routes.py b/api/routes.py index 2330585..af58959 100644 --- a/api/routes.py +++ b/api/routes.py @@ -2268,14 +2268,28 @@ async def lookup_episode(imdb_id: str, season: int, episode: int, dependencies: if nfo_manager and config: print(f"DEBUG: Auto-fixing NFO for episode {imdb_id} S{season:02d}E{episode:02d}") - # Find the series directory using the same logic NFOGuard uses + # Find the series directory using filesystem search from pathlib import Path - tv_library_path = Path(config.tv_library_path) + + # Search common TV library paths based on the logs we see from Emby + tv_search_paths = [ + Path("/media/TV"), + Path("/mnt/unionfs/Media/TV"), + Path("/media/tv"), + Path("/mnt/unionfs/Media/TV/tv"), + Path("/mnt/unionfs/Media/TV/tv6") + ] # Look for series directory with IMDb ID pattern - import glob pattern = f"*[imdb-{imdb_id}]*" - series_matches = list(tv_library_path.glob(f"**/{pattern}")) + series_matches = [] + + for search_path in tv_search_paths: + if search_path.exists(): + matches = list(search_path.glob(f"**/{pattern}")) + series_matches.extend(matches) + if matches: + break # Use first successful search path if series_matches: series_dir = series_matches[0] # Take first match @@ -2298,7 +2312,7 @@ async def lookup_episode(imdb_id: str, season: int, episode: int, dependencies: else: print(f"WARNING: Season directory not found: {season_dir}") else: - print(f"WARNING: Series directory not found for {imdb_id} in {tv_library_path}") + print(f"WARNING: Series directory not found for {imdb_id} in any search paths: {[str(p) for p in tv_search_paths]}") else: print(f"DEBUG: Auto-fix skipped - nfo_manager: {nfo_manager is not None}, config: {config is not None}") except Exception as fix_error: @@ -2368,13 +2382,26 @@ async def lookup_movie(imdb_id: str, dependencies: dict): if nfo_manager and config: print(f"DEBUG: Auto-fixing NFO for movie {imdb_id}") - # Find the movie directory using the same logic NFOGuard uses + # Find the movie directory using filesystem search from pathlib import Path - movie_library_path = Path(config.movie_library_path) + + # Search common movie library paths + movie_search_paths = [ + Path("/media/Movies"), + Path("/mnt/unionfs/Media/Movies"), + Path("/media/movies") + ] # Look for movie directory with IMDb ID pattern pattern = f"*[imdb-{imdb_id}]*" - movie_matches = list(movie_library_path.glob(f"**/{pattern}")) + movie_matches = [] + + for search_path in movie_search_paths: + if search_path.exists(): + matches = list(search_path.glob(f"**/{pattern}")) + movie_matches.extend(matches) + if matches: + break # Use first successful search path if movie_matches: movie_dir = movie_matches[0] # Take first match @@ -2394,7 +2421,7 @@ async def lookup_movie(imdb_id: str, dependencies: dict): else: print(f"WARNING: Movie directory not found: {movie_dir}") else: - print(f"WARNING: Movie directory not found for {imdb_id} in {movie_library_path}") + print(f"WARNING: Movie directory not found for {imdb_id} in any search paths: {[str(p) for p in movie_search_paths]}") else: print(f"DEBUG: Auto-fix skipped - nfo_manager: {nfo_manager is not None}, config: {config is not None}") except Exception as fix_error: