From cb415531d8082e13a744c7a0fc34aefa87f758c5 Mon Sep 17 00:00:00 2001 From: Anderson Shindy Oki Date: Tue, 16 Jul 2024 11:52:26 +0900 Subject: [PATCH] Fixed anidb refiner episode not found (#2581) --- bazarr/subtitles/refiners/anidb.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/bazarr/subtitles/refiners/anidb.py b/bazarr/subtitles/refiners/anidb.py index f3c61916a..36ed05786 100644 --- a/bazarr/subtitles/refiners/anidb.py +++ b/bazarr/subtitles/refiners/anidb.py @@ -83,9 +83,9 @@ class AniDBClient(object): for index, anime_info in enumerate(animes): anime, episode_offset = anime_info - anidb_id = int(anime.attrib.get('anidbid')) + if episode > episode_offset: - anidb_id = anidb_id + anidb_id = int(anime.attrib.get('anidbid')) offset = episode_offset return anidb_id, episode - offset @@ -101,7 +101,12 @@ class AniDBClient(object): episodes = etree.fromstring(self.get_episodes(series_id)) - return series_id, int(episodes.find(f".//episode[epno='{episode_no}']").attrib.get('id')) + episode = episodes.find(f".//episode[epno='{episode_no}']") + + if not episode: + return series_id, None + + return series_id, int(episode.attrib.get('id')) @region.cache_on_arguments(expiration_time=REFINER_EXPIRATION_TIME) def get_episodes(self, series_id):