From 0980ba076121561e039023bae31f3c61d219efee Mon Sep 17 00:00:00 2001 From: sbcrumb Date: Sat, 4 Oct 2025 11:41:35 -0400 Subject: [PATCH] Fix TV processing issues: correct method names and add missing episode air date method - Fix SonarrClient method call from get_series_by_imdb to series_by_imdb - Fix SonarrClient method call from get_episodes to episodes_for_series - Add missing get_episode_air_date method to ExternalClientManager - Method uses TMDB and OMDb APIs to fetch episode air dates - Version bump to 2.0.7 --- VERSION | 2 +- clients/external_clients.py | 30 ++++++++++++++++++++++++++++++ processors/tv_processor.py | 4 ++-- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index 157e54f..f1547e6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.0.6 +2.0.7 diff --git a/clients/external_clients.py b/clients/external_clients.py index 4c15520..07a750a 100644 --- a/clients/external_clients.py +++ b/clients/external_clients.py @@ -659,6 +659,36 @@ class ExternalClientManager: return None return self.tvdb.imdb_to_tvdb_series_id(imdb_id) + + def get_episode_air_date(self, imdb_id: str, season: int, episode: int) -> Optional[str]: + """Get episode air date from external sources""" + _log("DEBUG", f"Looking for air date for {imdb_id} S{season:02d}E{episode:02d}") + + # Try TMDB first if available + if self.tmdb.enabled: + # Find TV show by IMDB ID + tv_find_result = self.tmdb._get(f"/find/{imdb_id}", {"external_source": "imdb_id"}) + if tv_find_result and tv_find_result.get("tv_results"): + tv_show = tv_find_result["tv_results"][0] + tv_id = tv_show.get("id") + if tv_id: + _log("DEBUG", f"Found TMDB TV ID {tv_id} for {imdb_id}") + episodes = self.tmdb.get_tv_season_episodes(tv_id, season) + if episode in episodes: + air_date = episodes[episode] + _log("INFO", f"Found TMDB air date for {imdb_id} S{season:02d}E{episode:02d}: {air_date}") + return _parse_date_to_iso(air_date) + + # Try OMDb as fallback + if self.omdb.enabled: + episodes = self.omdb.get_tv_season_episodes(imdb_id, season) + if episode in episodes: + air_date = episodes[episode] + _log("INFO", f"Found OMDb air date for {imdb_id} S{season:02d}E{episode:02d}: {air_date}") + return _parse_date_to_iso(air_date) + + _log("WARNING", f"No air date found for {imdb_id} S{season:02d}E{episode:02d}") + return None if __name__ == "__main__": diff --git a/processors/tv_processor.py b/processors/tv_processor.py index ed351ae..88eb992 100644 --- a/processors/tv_processor.py +++ b/processors/tv_processor.py @@ -142,7 +142,7 @@ class TVProcessor: def _get_sonarr_episodes(self, imdb_id: str) -> Dict[Tuple[int, int], Dict[str, Any]]: """Get episode information from Sonarr""" try: - series_data = self.sonarr.get_series_by_imdb(imdb_id) + series_data = self.sonarr.series_by_imdb(imdb_id) if not series_data: return {} @@ -150,7 +150,7 @@ class TVProcessor: if not series_id: return {} - episodes = self.sonarr.get_episodes(series_id) + episodes = self.sonarr.episodes_for_series(series_id) episode_map = {} for episode in episodes: