From b709a377c8f5fe6ca0890eb0c4b163970b4e184c Mon Sep 17 00:00:00 2001 From: SBCrumb Date: Tue, 28 Oct 2025 17:00:56 -0400 Subject: [PATCH] update: to handle specials --- api/routes.py | 2 +- api/web_routes.py | 2 +- config/settings.py | 6 ++++++ processors/tv_processor.py | 12 ++++++------ 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/api/routes.py b/api/routes.py index 29869e3..fc78370 100644 --- a/api/routes.py +++ b/api/routes.py @@ -2198,7 +2198,7 @@ async def update_episode_nfo(imdb_id: str, season: int, episode: int, request: R return {"success": False, "message": f"Series directory not found for {imdb_id}"} # Get season directory - season_dir = series_path / config.tv_season_dir_format.format(season=season) + season_dir = series_path / config.get_season_dir_name(season) if not season_dir.exists(): return {"success": False, "message": f"Season directory not found: {season_dir}"} diff --git a/api/web_routes.py b/api/web_routes.py index c6ddc12..69b6e5c 100644 --- a/api/web_routes.py +++ b/api/web_routes.py @@ -1796,7 +1796,7 @@ async def bulk_update_nfo_files(dependencies: dict, imdb_ids: list = None, fix_a for ep in episodes: try: series_path = Path(ep['series_path']) - season_dir = series_path / config.tv_season_dir_format.format(season=ep['season']) + season_dir = series_path / config.get_season_dir_name(ep['season']) if not season_dir.exists(): continue diff --git a/config/settings.py b/config/settings.py index 5ef8290..ef45414 100644 --- a/config/settings.py +++ b/config/settings.py @@ -172,6 +172,12 @@ class NFOGuardConfig: self.tv_season_dir_format = os.environ.get("TV_SEASON_DIR_FORMAT", "Season {season:02d}") self.tv_season_dir_pattern = os.environ.get("TV_SEASON_DIR_PATTERN", "season ").lower() self.tv_webhook_processing_mode = os.environ.get("TV_WEBHOOK_PROCESSING_MODE", "targeted").lower() + + def get_season_dir_name(self, season: int) -> str: + """Get the directory name for a specific season, handling Season 0 as 'Specials'""" + if season == 0: + return "Specials" + return self.tv_season_dir_format.format(season=season) def _load_auth_settings(self) -> None: """Load web interface authentication settings""" diff --git a/processors/tv_processor.py b/processors/tv_processor.py index 9312cec..cb68f3a 100644 --- a/processors/tv_processor.py +++ b/processors/tv_processor.py @@ -194,7 +194,7 @@ class TVProcessor: # Create NFO if config.manage_nfo: - season_dir = series_path / config.tv_season_dir_format.format(season=season) + season_dir = series_path / config.get_season_dir_name(season) self.nfo_manager.create_episode_nfo( season_dir, season, episode, aired, dateadded, source, config.lock_metadata @@ -264,7 +264,7 @@ class TVProcessor: for (season, episode) in episodes_needing_nfo_check: # Look for existing NFO files for this episode - season_dir = series_path / config.tv_season_dir_format.format(season=season) + season_dir = series_path / config.get_season_dir_name(season) episode_files = disk_episodes[(season, episode)] nfo_found = False @@ -656,7 +656,7 @@ class TVProcessor: for (season, episode), (aired, dateadded, source) in episode_dates.items(): if (season, episode) in disk_episodes: - season_dir = series_path / config.tv_season_dir_format.format(season=season) + season_dir = series_path / config.get_season_dir_name(season) # Prepare NFO creation data if config.manage_nfo: @@ -789,7 +789,7 @@ class TVProcessor: continue # Check if episode file exists on disk - season_dir = series_path / config.tv_season_dir_format.format(season=season_num) + season_dir = series_path / config.get_season_dir_name(season_num) if not season_dir.exists(): _log("WARNING", f"Season directory not found: {season_dir}") continue @@ -842,7 +842,7 @@ class TVProcessor: # for webhook_episode in webhook_episodes: # season_num = webhook_episode.get("seasonNumber") # if season_num and season_num not in seasons_processed: - # season_dir = series_path / config.tv_season_dir_format.format(season=season_num) + # season_dir = series_path / config.get_season_dir_name(season_num) # if season_dir.exists(): # self.nfo_manager.create_season_nfo(season_dir, season_num) # seasons_processed.add(season_num) @@ -1084,7 +1084,7 @@ class TVProcessor: # Create NFO if needed nfo_success = True if config.manage_nfo: - season_dir = series_path / config.tv_season_dir_format.format(season=season) + season_dir = series_path / config.get_season_dir_name(season) nfo_success = await self.async_nfo_manager.async_create_episode_nfo( season_dir, season, episode, aired, dateadded, "webhook", config.lock_metadata )