[2] Fixed multiple anime int() Errors (#2099)

This commit is contained in:
meisnate12 2024-06-06 09:16:57 -04:00 committed by GitHub Action
parent e4c5ef60ab
commit 3af2dee7c5
4 changed files with 173 additions and 170 deletions

View file

@ -10,5 +10,6 @@ Added [`letterboxd_user_lists`](https://kometa.wiki/en/latest/files/dynamic_type
# Defaults # Defaults
# Bug Fixes # Bug Fixes
Fixed multiple anime `int()` Errors
Various other Minor Fixes Various other Minor Fixes

View file

@ -1 +1 @@
2.0.2-build1 2.0.2-build2

View file

@ -2234,179 +2234,183 @@ class CollectionBuilder:
logger.trace(f"IDs: {ids}") logger.trace(f"IDs: {ids}")
logger.debug("") logger.debug("")
for i, input_data in enumerate(ids, 1): for i, input_data in enumerate(ids, 1):
input_id, id_type = input_data try:
logger.ghost(f"Parsing ID {i}/{total_ids}") input_id, id_type = input_data
rating_keys = [] logger.ghost(f"Parsing ID {i}/{total_ids}")
if id_type == "ratingKey": rating_keys = []
rating_keys = int(input_id) if id_type == "ratingKey":
elif id_type == "imdb": rating_keys = int(input_id)
if input_id not in self.ignore_imdb_ids: elif id_type == "imdb":
if input_id not in self.ignore_imdb_ids:
found = False
for pl_library in self.libraries:
if input_id in pl_library.imdb_map:
found = True
rating_keys = pl_library.imdb_map[input_id]
break
if not found and (self.builder_level == "episode" or self.playlist or self.do_missing):
try:
_id, tmdb_type = self.config.Convert.imdb_to_tmdb(input_id, fail=True)
if tmdb_type == "episode" and (self.builder_level == "episode" or self.playlist):
try:
tmdb_id, season_num, episode_num = _id.split("_")
tvdb_id = self.config.Convert.tmdb_to_tvdb(tmdb_id, fail=True)
tvdb_id = int(tvdb_id)
except Failed as e:
try:
if not self.config.OMDb:
raise Failed("")
if self.config.OMDb.limit:
raise Failed(" and OMDb limit reached.")
omdb_item = self.config.OMDb.get_omdb(input_id)
tvdb_id = omdb_item.series_id
season_num = omdb_item.season_num
episode_num = omdb_item.episode_num
if not tvdb_id or not season_num or not episode_num:
raise Failed(f" and OMDb metadata lookup Failed for IMDb ID: {input_id}")
except Failed as ee:
logger.error(f"{e}{ee}")
continue
for pl_library in self.libraries:
if tvdb_id in pl_library.show_map:
found = True
show_item = pl_library.fetch_item(pl_library.show_map[tvdb_id][0])
try:
items.append(show_item.episode(season=int(season_num), episode=int(episode_num)))
except NotFound:
self.missing_parts.append(f"{show_item.title} Season: {season_num} Episode: {episode_num} Missing")
break
if not found and tvdb_id not in self.missing_shows and self.do_missing:
self.missing_shows.append(tvdb_id)
elif tmdb_type == "movie" and self.do_missing and _id not in self.missing_movies:
self.missing_movies.append(_id)
elif tmdb_type in ["show", "episode"] and self.do_missing:
if tmdb_type == "episode":
tmdb_id, _, _ = _id.split("_")
else:
tmdb_id = _id
tvdb_id = self.config.Convert.tmdb_to_tvdb(tmdb_id, fail=True)
if tvdb_id not in self.missing_shows:
self.missing_shows.append(tvdb_id)
except Failed as e:
logger.warning(e)
continue
elif id_type == "tmdb" and not self.parts_collection:
input_id = int(input_id)
if input_id not in self.ignore_ids:
found = False
for pl_library in self.libraries:
if input_id in pl_library.movie_map:
found = True
rating_keys = pl_library.movie_map[input_id]
break
if not found and input_id not in self.missing_movies:
self.missing_movies.append(input_id)
elif id_type == "tvdb_season" and (self.builder_level == "season" or self.playlist):
tvdb_id, season_num = input_id.split("_")
tvdb_id = int(tvdb_id)
found = False found = False
for pl_library in self.libraries: for pl_library in self.libraries:
if input_id in pl_library.imdb_map: if tvdb_id in pl_library.show_map:
found = True found = True
rating_keys = pl_library.imdb_map[input_id] show_item = pl_library.fetch_item(pl_library.show_map[tvdb_id][0])
break try:
if not found and (self.builder_level == "episode" or self.playlist or self.do_missing): season_obj = show_item.season(season=int(season_num))
try: if self.playlist:
_id, tmdb_type = self.config.Convert.imdb_to_tmdb(input_id, fail=True) items.extend(season_obj.episodes())
if tmdb_type == "episode" and (self.builder_level == "episode" or self.playlist):
try:
tmdb_id, season_num, episode_num = _id.split("_")
tvdb_id = self.config.Convert.tmdb_to_tvdb(tmdb_id, fail=True)
tvdb_id = int(tvdb_id)
except Failed as e:
try:
if not self.config.OMDb:
raise Failed("")
if self.config.OMDb.limit:
raise Failed(" and OMDb limit reached.")
omdb_item = self.config.OMDb.get_omdb(input_id)
tvdb_id = omdb_item.series_id
season_num = omdb_item.season_num
episode_num = omdb_item.episode_num
if not tvdb_id or not season_num or not episode_num:
raise Failed(f" and OMDb metadata lookup Failed for IMDb ID: {input_id}")
except Failed as ee:
logger.error(f"{e}{ee}")
continue
for pl_library in self.libraries:
if tvdb_id in pl_library.show_map:
found = True
show_item = pl_library.fetch_item(pl_library.show_map[tvdb_id][0])
try:
items.append(show_item.episode(season=int(season_num), episode=int(episode_num)))
except NotFound:
self.missing_parts.append(f"{show_item.title} Season: {season_num} Episode: {episode_num} Missing")
break
if not found and tvdb_id not in self.missing_shows and self.do_missing:
self.missing_shows.append(tvdb_id)
elif tmdb_type == "movie" and self.do_missing and _id not in self.missing_movies:
self.missing_movies.append(_id)
elif tmdb_type in ["show", "episode"] and self.do_missing:
if tmdb_type == "episode":
tmdb_id, _, _ = _id.split("_")
else: else:
tmdb_id = _id items.append(season_obj)
tvdb_id = self.config.Convert.tmdb_to_tvdb(tmdb_id, fail=True) except NotFound:
if tvdb_id not in self.missing_shows: self.missing_parts.append(f"{show_item.title} Season: {season_num} Missing")
self.missing_shows.append(tvdb_id) break
if not found and tvdb_id not in self.missing_shows:
self.missing_shows.append(tvdb_id)
elif id_type == "tvdb_episode" and (self.builder_level == "episode" or self.playlist):
tvdb_id, season_num, episode_num = input_id.split("_")
tvdb_id = int(tvdb_id)
found = False
for pl_library in self.libraries:
if tvdb_id in pl_library.show_map:
found = True
show_item = pl_library.fetch_item(pl_library.show_map[tvdb_id][0])
try:
items.append(show_item.episode(season=int(season_num), episode=int(episode_num)))
except NotFound:
self.missing_parts.append(f"{show_item.title} Season: {season_num} Episode: {episode_num} Missing")
if not found and tvdb_id not in self.missing_shows and self.do_missing:
self.missing_shows.append(tvdb_id)
elif id_type in ["tvdb", "tmdb_show", "tvdb_season", "tvdb_episode"]:
tvdb_season = None
if id_type == "tmdb_show":
try:
tvdb_id = self.config.Convert.tmdb_to_tvdb(input_id, fail=True)
except Failed as e: except Failed as e:
logger.warning(e) logger.warning(e)
continue continue
elif id_type == "tmdb" and not self.parts_collection: elif id_type == "tvdb_season":
input_id = int(input_id) tvdb_id, tvdb_season = input_id.split("_")
if input_id not in self.ignore_ids: tvdb_id = int(tvdb_id)
found = False tvdb_season = int(tvdb_season)
for pl_library in self.libraries: elif id_type == "tvdb_episode":
if input_id in pl_library.movie_map: tvdb_id, _, _ = input_id.split("_")
found = True tvdb_id = int(tvdb_id)
rating_keys = pl_library.movie_map[input_id]
break
if not found and input_id not in self.missing_movies:
self.missing_movies.append(input_id)
elif id_type == "tvdb_season" and (self.builder_level == "season" or self.playlist):
tvdb_id, season_num = input_id.split("_")
tvdb_id = int(tvdb_id)
found = False
for pl_library in self.libraries:
if tvdb_id in pl_library.show_map:
found = True
show_item = pl_library.fetch_item(pl_library.show_map[tvdb_id][0])
try:
season_obj = show_item.season(season=int(season_num))
if self.playlist:
items.extend(season_obj.episodes())
else:
items.append(season_obj)
except NotFound:
self.missing_parts.append(f"{show_item.title} Season: {season_num} Missing")
break
if not found and tvdb_id not in self.missing_shows:
self.missing_shows.append(tvdb_id)
elif id_type == "tvdb_episode" and (self.builder_level == "episode" or self.playlist):
tvdb_id, season_num, episode_num = input_id.split("_")
tvdb_id = int(tvdb_id)
found = False
for pl_library in self.libraries:
if tvdb_id in pl_library.show_map:
found = True
show_item = pl_library.fetch_item(pl_library.show_map[tvdb_id][0])
try:
items.append(show_item.episode(season=int(season_num), episode=int(episode_num)))
except NotFound:
self.missing_parts.append(f"{show_item.title} Season: {season_num} Episode: {episode_num} Missing")
if not found and tvdb_id not in self.missing_shows and self.do_missing:
self.missing_shows.append(tvdb_id)
elif id_type in ["tvdb", "tmdb_show", "tvdb_season", "tvdb_episode"]:
tvdb_season = None
if id_type == "tmdb_show":
try:
tvdb_id = self.config.Convert.tmdb_to_tvdb(input_id, fail=True)
except Failed as e:
logger.warning(e)
continue
elif id_type == "tvdb_season":
tvdb_id, tvdb_season = input_id.split("_")
tvdb_id = int(tvdb_id)
tvdb_season = int(tvdb_season)
elif id_type == "tvdb_episode":
tvdb_id, _, _ = input_id.split("_")
tvdb_id = int(tvdb_id)
else:
tvdb_id = int(input_id)
if tvdb_id not in self.ignore_ids:
found_keys = None
for pl_library in self.libraries:
if tvdb_id in pl_library.show_map:
found_keys = pl_library.show_map[tvdb_id]
break
if not found_keys and tvdb_id not in self.missing_shows:
self.missing_shows.append(tvdb_id)
if found_keys:
if self.parts_collection:
rating_keys = []
for rk in found_keys:
try:
item = self.library.fetch_item(rk)
if self.builder_level == "episode" and isinstance(item, Show):
if tvdb_season is not None:
item = item.season(season=tvdb_season)
rating_keys.extend([k.ratingKey for k in item.episodes()])
elif self.builder_level == "season" and isinstance(item, Show):
rating_keys.extend([k.ratingKey for k in item.seasons()])
except Failed as e:
logger.error(e)
else:
rating_keys = found_keys
else:
continue
if not isinstance(rating_keys, list):
rating_keys = [rating_keys]
for rk in rating_keys:
try:
item = self.library.fetch_item(rk)
if self.playlist and isinstance(item, (Show, Season)):
items.extend(item.episodes())
elif self.builder_level == "movie" and not isinstance(item, Movie):
logger.info(f"Item: {item} is not an Movie")
elif self.builder_level == "show" and not isinstance(item, Show):
logger.info(f"Item: {item} is not an Show")
elif self.builder_level == "episode" and not isinstance(item, Episode):
logger.info(f"Item: {item} is not an Episode")
elif self.builder_level == "season" and not isinstance(item, Season):
logger.info(f"Item: {item} is not a Season")
elif self.builder_level == "artist" and not isinstance(item, Artist):
logger.info(f"Item: {item} is not an Artist")
elif self.builder_level == "album" and not isinstance(item, Album):
logger.info(f"Item: {item} is not an Album")
elif self.builder_level == "track" and not isinstance(item, Track):
logger.info(f"Item: {item} is not a Track")
else: else:
items.append(item) tvdb_id = int(input_id)
except Failed as e: if tvdb_id not in self.ignore_ids:
logger.error(e) found_keys = None
for pl_library in self.libraries:
if tvdb_id in pl_library.show_map:
found_keys = pl_library.show_map[tvdb_id]
break
if not found_keys and tvdb_id not in self.missing_shows:
self.missing_shows.append(tvdb_id)
if found_keys:
if self.parts_collection:
rating_keys = []
for rk in found_keys:
try:
item = self.library.fetch_item(rk)
if self.builder_level == "episode" and isinstance(item, Show):
if tvdb_season is not None:
item = item.season(season=tvdb_season)
rating_keys.extend([k.ratingKey for k in item.episodes()])
elif self.builder_level == "season" and isinstance(item, Show):
rating_keys.extend([k.ratingKey for k in item.seasons()])
except Failed as e:
logger.error(e)
else:
rating_keys = found_keys
else:
continue
if not isinstance(rating_keys, list):
rating_keys = [rating_keys]
for rk in rating_keys:
try:
item = self.library.fetch_item(rk)
if self.playlist and isinstance(item, (Show, Season)):
items.extend(item.episodes())
elif self.builder_level == "movie" and not isinstance(item, Movie):
logger.info(f"Item: {item} is not an Movie")
elif self.builder_level == "show" and not isinstance(item, Show):
logger.info(f"Item: {item} is not an Show")
elif self.builder_level == "episode" and not isinstance(item, Episode):
logger.info(f"Item: {item} is not an Episode")
elif self.builder_level == "season" and not isinstance(item, Season):
logger.info(f"Item: {item} is not a Season")
elif self.builder_level == "artist" and not isinstance(item, Artist):
logger.info(f"Item: {item} is not an Artist")
elif self.builder_level == "album" and not isinstance(item, Album):
logger.info(f"Item: {item} is not an Album")
elif self.builder_level == "track" and not isinstance(item, Track):
logger.info(f"Item: {item} is not a Track")
else:
items.append(item)
except Failed as e:
logger.error(e)
except Exception as e:
logger.stacktrace()
logger.error(e)
logger.info(input_data)
logger.exorcise() logger.exorcise()
if not items: if not items:
return None return None

View file

@ -69,10 +69,10 @@ class Convert:
def ids_to_anidb(self, library, rating_key, tvdb_id, imdb_id, tmdb_id): def ids_to_anidb(self, library, rating_key, tvdb_id, imdb_id, tmdb_id):
if rating_key in library.reverse_anidb: if rating_key in library.reverse_anidb:
return library.reverse_anidb[rating_key] return library.reverse_anidb[rating_key]
elif int(tvdb_id) in self._tvdb_to_anidb: elif tvdb_id and int(tvdb_id) in self._tvdb_to_anidb:
return self._tvdb_to_anidb[int(tvdb_id)] return self._tvdb_to_anidb[int(tvdb_id)]
else: else:
tmdb_show_id = self.tvdb_to_tmdb(tvdb_id) tmdb_show_id = self.tvdb_to_tmdb(tvdb_id) if tvdb_id else None
if tmdb_show_id and tmdb_show_id in self._tmdb_show_to_anidb: if tmdb_show_id and tmdb_show_id in self._tmdb_show_to_anidb:
return self._tmdb_show_to_anidb[tmdb_show_id] return self._tmdb_show_to_anidb[tmdb_show_id]
elif imdb_id in self._imdb_to_anidb: elif imdb_id in self._imdb_to_anidb:
@ -109,7 +109,6 @@ class Convert:
added = True added = True
if added is False and anidb_id in self._anidb_to_tvdb: if added is False and anidb_id in self._anidb_to_tvdb:
ids.append((self._anidb_to_tvdb[anidb_id], "tvdb")) ids.append((self._anidb_to_tvdb[anidb_id], "tvdb"))
ids.append((self._anidb_to_tmdb_movie[anidb_id], "tmdb"))
elif anidb_id in self._anidb_to_tvdb: elif anidb_id in self._anidb_to_tvdb:
ids.append((self._anidb_to_tvdb[anidb_id], "tvdb")) ids.append((self._anidb_to_tvdb[anidb_id], "tvdb"))
elif anidb_id in self._anidb_to_tmdb_show: elif anidb_id in self._anidb_to_tmdb_show:
@ -118,7 +117,6 @@ class Convert:
ids.append((int(self.tmdb_to_tvdb(tmdb_id, fail=True)), "tvdb")) ids.append((int(self.tmdb_to_tvdb(tmdb_id, fail=True)), "tvdb"))
except Failed: except Failed:
pass pass
ids.append((self._anidb_to_tmdb_show[anidb_id], "tmdb"))
elif str(anidb_id) in self._anidb_ids: elif str(anidb_id) in self._anidb_ids:
logger.warning(f"Convert Warning: No TVDb ID or IMDb ID found for AniDB ID: {anidb_id}") logger.warning(f"Convert Warning: No TVDb ID or IMDb ID found for AniDB ID: {anidb_id}")
else: else: