#369 fix anilist_search and tvdb ids

pull/392/head
meisnate12 3 years ago
parent e6fd8bf92c
commit 585bd44e3a

@ -102,7 +102,7 @@ class AniList:
if attr in ["start", "end"]: if attr in ["start", "end"]:
value = int(util.validate_date(value, f"anilist_search {key}", return_as="%Y%m%d")) value = int(util.validate_date(value, f"anilist_search {key}", return_as="%Y%m%d"))
elif attr in ["season", "format", "status", "genre", "tag", "tag_category"]: elif attr in ["season", "format", "status", "genre", "tag", "tag_category"]:
value = self.options[attr.replace("_", " ").title()][value.lower().replace(" / ", "-").replace(" ", "-")] value = [self.options[attr.replace("_", " ").title()][v.lower().replace(" / ", "-").replace(" ", "-")] for v in value]
if mod == "gte": if mod == "gte":
value -= 1 value -= 1
elif mod == "lte": elif mod == "lte":
@ -178,8 +178,7 @@ class AniList:
def validate(self, name, data): def validate(self, name, data):
valid = [] valid = []
for d in util.get_list(data): for d in util.get_list(data):
data_check = d.lower().replace(" / ", "-").replace(" ", "-") if d.lower().replace(" / ", "-").replace(" ", "-") in self.options[name]:
if data_check in self.options[name]:
valid.append(d) valid.append(d)
if len(valid) > 0: if len(valid) > 0:
return valid return valid

@ -1122,12 +1122,12 @@ class CollectionBuilder:
else: else:
if self.do_missing: if self.do_missing:
try: try:
tmdb_id, tmdb_type = self.config.Convert.imdb_to_tmdb(input_id) tmdb_id, tmdb_type = self.config.Convert.imdb_to_tmdb(input_id, fail=True)
if tmdb_type == "movie": if tmdb_type == "movie":
if tmdb_id not in self.missing_movies: if tmdb_id not in self.missing_movies:
self.missing_movies.append(tmdb_id) self.missing_movies.append(tmdb_id)
else: else:
tvdb_id = self.config.Convert.tmdb_to_tvdb(tmdb_id) tvdb_id = self.config.Convert.tmdb_to_tvdb(tmdb_id, fail=True)
if tvdb_id not in self.missing_shows: if tvdb_id not in self.missing_shows:
self.missing_shows.append(tvdb_id) self.missing_shows.append(tvdb_id)
except Failed as e: except Failed as e:
@ -1135,26 +1135,28 @@ class CollectionBuilder:
continue continue
elif id_type == "tvdb_season" and self.collection_level == "season": elif id_type == "tvdb_season" and self.collection_level == "season":
show_id, season_num = input_id.split("_") show_id, season_num = input_id.split("_")
if int(show_id) in self.library.show_map: show_id = int(show_id)
show_item = self.library.fetchItem(self.library.show_map[int(show_id)][0]) if show_id in self.library.show_map:
show_item = self.library.fetchItem(self.library.show_map[show_id][0])
try: try:
episode_item = show_item.season(season=int(season_num)) episode_item = show_item.season(season=int(season_num))
rating_keys.append(episode_item.ratingKey) rating_keys.append(episode_item.ratingKey)
except NotFound: except NotFound:
self.missing_parts.append(f"{show_item.title} Season: {season_num} Missing") self.missing_parts.append(f"{show_item.title} Season: {season_num} Missing")
elif int(show_id) not in self.missing_shows: elif show_id not in self.missing_shows:
self.missing_shows.append(int(show_id)) self.missing_shows.append(show_id)
elif id_type == "tvdb_episode" and self.collection_level == "episode": elif id_type == "tvdb_episode" and self.collection_level == "episode":
show_id, season_num, episode_num = input_id.split("_") show_id, season_num, episode_num = input_id.split("_")
if int(show_id) in self.library.show_map: show_id = int(show_id)
show_item = self.library.fetchItem(self.library.show_map[int(show_id)][0]) if show_id in self.library.show_map:
show_item = self.library.fetchItem(self.library.show_map[show_id][0])
try: try:
episode_item = show_item.episode(season=int(season_num), episode=int(episode_num)) episode_item = show_item.episode(season=int(season_num), episode=int(episode_num))
rating_keys.append(episode_item.ratingKey) rating_keys.append(episode_item.ratingKey)
except NotFound: except NotFound:
self.missing_parts.append(f"{show_item.title} Season: {season_num} Episode: {episode_num} Missing") self.missing_parts.append(f"{show_item.title} Season: {season_num} Episode: {episode_num} Missing")
elif int(show_id) not in self.missing_shows: elif show_id not in self.missing_shows:
self.missing_shows.append(int(show_id)) self.missing_shows.append(show_id)
util.print_end() util.print_end()
if len(rating_keys) > 0: if len(rating_keys) > 0:

Loading…
Cancel
Save