Skip to content

Commit

Permalink
Merge pull request #536 from BeeeQueue/arm-update
Browse files Browse the repository at this point in the history
Improve AniList Logic
  • Loading branch information
ZeroQI authored Jan 5, 2023
2 parents b2a0ac4 + c8b8a52 commit 93b214d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Contents/Code/AniList.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from common import Log, DictString, Dict, SaveDict # Direct import of heavily used functions

### Variables ###
ARM_SERVER_URL = "https://relations.yuna.moe/api/ids?source=anidb&id={id}"
ARM_SERVER_URL = "https://arm.haglund.dev/api/v2/ids?source=anidb&include=anilist&id={id}"

GRAPHQL_API_URL = "https://graphql.anilist.co"
ANIME_DATA_DOCUMENT = """
Expand Down 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 93b214d

Please sign in to comment.