Skip to content

Commit

Permalink
arms update
Browse files Browse the repository at this point in the history
  • Loading branch information
meisnate12 committed Apr 23, 2021
1 parent 1a70b7d commit 0504870
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions modules/arms.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@ def _anidb(self, input_id, to_id):
return ids[0].split(",") if to_id == "imdbid" else int(ids[0])
raise ValueError
except ValueError:
raise Failed(f"AniDB Error: No {util.pretty_ids[to_id]} ID found for AniDB ID: {input_id}")
raise Failed(f"Arms Error: No {util.pretty_ids[to_id]} ID found for AniDB ID: {input_id}")
else:
raise Failed(f"AniDB Error: AniDB ID: {input_id} not found")
raise Failed(f"Arms Error: AniDB ID: {input_id} not found")

@retry(stop_max_attempt_number=6, wait_fixed=10000)
def send_request(self, ids):
def _request(self, ids):
return requests.post(self.arms_url, json=ids).json()

def mal_to_anidb(self, mal_id):
anime_ids = self._arms_ids(mal_ids=mal_id)
if anime_ids[0] is None:
raise Failed(f"Arms Server Error: MyAnimeList ID: {mal_id} does not exist")
raise Failed(f"Arms Error: MyAnimeList ID: {mal_id} does not exist")
if anime_ids[0]["anidb"] is None:
raise Failed(f"Arms Server Error: No AniDB ID for MyAnimeList ID: {mal_id}")
raise Failed(f"Arms Error: No AniDB ID for MyAnimeList ID: {mal_id}")
return anime_ids[0]["anidb"]

def anidb_to_ids(self, anidb_list, language):
Expand All @@ -61,7 +61,7 @@ def anidb_to_ids(self, anidb_list, language):
if tvdb_id:
show_ids.append(tvdb_id)
except Failed:
logger.error(f"AniDB Error: No TVDb ID or IMDb ID found for AniDB ID: {anidb_id}")
logger.error(f"Arms Error: No TVDb ID or IMDb ID found for AniDB ID: {anidb_id}")
return movie_ids, show_ids

def anilist_to_ids(self, anilist_ids, language):
Expand All @@ -70,7 +70,7 @@ def anilist_to_ids(self, anilist_ids, language):
if id_set["anidb"] is not None:
anidb_ids.append(id_set["anidb"])
else:
logger.error(f"Convert Error: AniDB ID not found for AniList ID: {id_set['anilist']}")
logger.error(f"Arms Error: AniDB ID not found for AniList ID: {id_set['anilist']}")
return self.anidb_to_ids(anidb_ids, language)

def myanimelist_to_ids(self, mal_ids, language):
Expand All @@ -79,7 +79,7 @@ def myanimelist_to_ids(self, mal_ids, language):
if id_set["anidb"] is not None:
anidb_ids.append(id_set["anidb"])
else:
logger.error(f"Convert Error: AniDB ID not found for MyAnimeList ID: {id_set['myanimelist']}")
logger.error(f"Arms Error: AniDB ID not found for MyAnimeList ID: {id_set['myanimelist']}")
return self.anidb_to_ids(anidb_ids, language)

def _arms_ids(self, anilist_ids=None, anidb_ids=None, mal_ids=None):
Expand All @@ -106,7 +106,7 @@ def collect_ids(ids, id_name):
else:
unconverted_ids = all_ids

for anime_ids in self.send_request(unconverted_ids):
for anime_ids in self._request(unconverted_ids):
if anime_ids:
if self.config.Cache:
self.config.Cache.update_anime(False, anime_ids)
Expand Down Expand Up @@ -159,7 +159,7 @@ def imdb_to_ids(self, imdb_id, language):
try:
if tvdb_id and not from_cache: self.config.TVDb.get_series(language, tvdb_id)
except Failed: tvdb_id = None
if not tmdb_id and not tvdb_id: raise Failed(f"IMDb Error: No TMDb ID or TVDb ID found for IMDb: {imdb_id}")
if not tmdb_id and not tvdb_id: raise Failed(f"Arms Error: No TMDb ID or TVDb ID found for IMDb: {imdb_id}")
if self.config.Cache:
if tmdb_id and update_tmdb is not False:
self.config.Cache.update_imdb("movie", update_tmdb, imdb_id, tmdb_id)
Expand Down

0 comments on commit 0504870

Please sign in to comment.