diff --git a/VERSION b/VERSION index 66beabb..6ae756c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.9.8 +1.9.9 diff --git a/core/nfo_manager.py b/core/nfo_manager.py index 3882359..a582540 100644 --- a/core/nfo_manager.py +++ b/core/nfo_manager.py @@ -947,10 +947,25 @@ class NFOManager: return processed_count def update_episode_nfo_preserving_name(self, nfo_path: Path, season_num: int, episode_num: int, - aired: Optional[str], dateadded: Optional[str], source: str) -> bool: + aired: Optional[str], dateadded: Optional[str], source: str, + imdb_id: Optional[str] = None, tv_processor=None) -> bool: """Update existing TV episode NFO file while preserving its original filename""" if not nfo_path.exists(): return False + + # If no episode data provided and we have IMDb ID, try to fetch it + if (not aired or not dateadded) and imdb_id and tv_processor: + print(f"⚠️ Missing episode data for S{season_num:02d}E{episode_num:02d}, attempting to fetch from APIs") + try: + fetched_aired, fetched_dateadded = tv_processor._get_episode_dates_from_apis(imdb_id, season_num, episode_num) + if fetched_aired and not aired: + aired = fetched_aired + print(f"✅ Fetched aired date: {aired}") + if fetched_dateadded and not dateadded: + dateadded = fetched_dateadded + print(f"✅ Fetched dateadded: {dateadded}") + except Exception as e: + print(f"⚠️ Failed to fetch episode data: {e}") try: # Parse the existing NFO file diff --git a/processors/tv_processor.py b/processors/tv_processor.py index 2772a7f..ee3a08c 100644 --- a/processors/tv_processor.py +++ b/processors/tv_processor.py @@ -98,7 +98,8 @@ class TVProcessor: if existing_nfo: # Update existing NFO while preserving its filename self.nfo_manager.update_episode_nfo_preserving_name( - existing_nfo, season, episode, aired, dateadded, "file_update" + existing_nfo, season, episode, aired, dateadded, "file_update", + imdb_id, self ) else: # Fallback to standard creation if NFO not found