Skip to content

Commit

Permalink
improve logic to reduce wasted requests
Browse files Browse the repository at this point in the history
  • Loading branch information
beeequeue authored Jan 5, 2023
1 parent eb92059 commit c8b8a52
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Contents/Code/AniList.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,16 @@ def GetMetadata(AniDBid, MALid):
Log.Info("=== AniList.GetMetadata() ===".ljust(157, '='))
AniList_dict = {}

# Try to match the AniDB id to an AniList id as it has a higher chance of being correct
ALid = Dict(common.LoadFile(filename=AniDBid+'.json', relativeDirectory=os.path.join('AniList', 'json', 'AniDBid'), url=ARM_SERVER_URL.format(id=AniDBid)), "anilist", default=None)
# Only try to get AniList ID if we have a AniDB ID
if AniDBid is not None:
# Try to match the AniDB id to an AniList id as it has a higher chance of being correct
ALid = Dict(common.LoadFile(filename=AniDBid+'.json', relativeDirectory=os.path.join('AniList', 'json', 'AniDBid'), url=ARM_SERVER_URL.format(id=AniDBid)), "anilist", default=None)
else:
ALid = None

Log.Info("AniDBid={}, MALid={}, ALid={}".format(AniDBid, MALid, ALid))
if not MALid or not MALid.isdigit(): return AniList_dict
# Don't try to fetch data from AniList if we don't know what to fetch
if ALid is None and (MALid is None or not MALid.isdigit()): return AniList_dict

Log.Info("--- series ---".ljust(157, "-"))

Expand Down

0 comments on commit c8b8a52

Please sign in to comment.