Fix TV processing issues: correct method names and add missing episode air date method
Local Docker Build (Dev) / build-dev (pull_request) Successful in 24s
Local Docker Build (Dev) / build-dev (pull_request) Successful in 24s
- 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
This commit is contained in:
@@ -660,6 +660,36 @@ class ExternalClientManager:
|
|||||||
|
|
||||||
return self.tvdb.imdb_to_tvdb_series_id(imdb_id)
|
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__":
|
if __name__ == "__main__":
|
||||||
# Test the clients
|
# Test the clients
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ class TVProcessor:
|
|||||||
def _get_sonarr_episodes(self, imdb_id: str) -> Dict[Tuple[int, int], Dict[str, Any]]:
|
def _get_sonarr_episodes(self, imdb_id: str) -> Dict[Tuple[int, int], Dict[str, Any]]:
|
||||||
"""Get episode information from Sonarr"""
|
"""Get episode information from Sonarr"""
|
||||||
try:
|
try:
|
||||||
series_data = self.sonarr.get_series_by_imdb(imdb_id)
|
series_data = self.sonarr.series_by_imdb(imdb_id)
|
||||||
if not series_data:
|
if not series_data:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@@ -150,7 +150,7 @@ class TVProcessor:
|
|||||||
if not series_id:
|
if not series_id:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
episodes = self.sonarr.get_episodes(series_id)
|
episodes = self.sonarr.episodes_for_series(series_id)
|
||||||
|
|
||||||
episode_map = {}
|
episode_map = {}
|
||||||
for episode in episodes:
|
for episode in episodes:
|
||||||
|
|||||||
Reference in New Issue
Block a user