From 35a415baa43b7f49c873ddcef7923f841e5a333a Mon Sep 17 00:00:00 2001 From: Adam Haglund Date: Thu, 5 Jan 2023 03:19:13 +0100 Subject: [PATCH 1/4] update api url --- Contents/Code/AniList.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Contents/Code/AniList.py b/Contents/Code/AniList.py index bf13d148..f1185cc6 100644 --- a/Contents/Code/AniList.py +++ b/Contents/Code/AniList.py @@ -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 = """ From 24bf33bba9c8cbd5e2e043fc1e0c7b8b82e0f154 Mon Sep 17 00:00:00 2001 From: Adam Haglund Date: Thu, 5 Jan 2023 03:20:53 +0100 Subject: [PATCH 2/4] add mal id to arm response --- Contents/Code/AniList.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Contents/Code/AniList.py b/Contents/Code/AniList.py index f1185cc6..c209a33c 100644 --- a/Contents/Code/AniList.py +++ b/Contents/Code/AniList.py @@ -9,7 +9,7 @@ from common import Log, DictString, Dict, SaveDict # Direct import of heavily used functions ### Variables ### -ARM_SERVER_URL = "https://arm.haglund.dev/api/v2/ids?source=anidb&include=anilist&id={id}" +ARM_SERVER_URL = "https://arm.haglund.dev/api/v2/ids?source=anidb&include=anilist,myanimelist&id={id}" GRAPHQL_API_URL = "https://graphql.anilist.co" ANIME_DATA_DOCUMENT = """ From eb92059e94a473e8427cb27810b5ea069d1491d4 Mon Sep 17 00:00:00 2001 From: Adam Haglund Date: Thu, 5 Jan 2023 03:21:56 +0100 Subject: [PATCH 3/4] nerevmind --- Contents/Code/AniList.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Contents/Code/AniList.py b/Contents/Code/AniList.py index c209a33c..f1185cc6 100644 --- a/Contents/Code/AniList.py +++ b/Contents/Code/AniList.py @@ -9,7 +9,7 @@ from common import Log, DictString, Dict, SaveDict # Direct import of heavily used functions ### Variables ### -ARM_SERVER_URL = "https://arm.haglund.dev/api/v2/ids?source=anidb&include=anilist,myanimelist&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 = """ From c8b8a52fc07d6305a47d13a426a6d249c85024b7 Mon Sep 17 00:00:00 2001 From: Adam Haglund Date: Thu, 5 Jan 2023 03:46:29 +0100 Subject: [PATCH 4/4] improve logic to reduce wasted requests --- Contents/Code/AniList.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Contents/Code/AniList.py b/Contents/Code/AniList.py index f1185cc6..17514aef 100644 --- a/Contents/Code/AniList.py +++ b/Contents/Code/AniList.py @@ -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, "-"))