From a961776a3c3597a4af97c492b53d370cfa261528 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Mon, 16 Sep 2024 16:06:05 +0800 Subject: [PATCH] fix --- .../LunaTranslator/metadata/vndb.py | 50 ++++--------------- 1 file changed, 10 insertions(+), 40 deletions(-) diff --git a/LunaTranslator/LunaTranslator/metadata/vndb.py b/LunaTranslator/LunaTranslator/metadata/vndb.py index 70bd85c8..66a665ee 100644 --- a/LunaTranslator/LunaTranslator/metadata/vndb.py +++ b/LunaTranslator/LunaTranslator/metadata/vndb.py @@ -94,7 +94,7 @@ def getinfosbyvid(proxy, vid): "vn", { "filters": ["id", "=", vid], - "fields": "tags.rating,tags.name,title,titles.title,titles.main,screenshots.url,image.url,developers.name,developers.original", + "fields": "tags.rating,tags.name,title,titles.title,titles.main,screenshots.url,image.url,developers.name,developers.original,va.character.name,va.character.original", }, ) if js: @@ -113,7 +113,15 @@ def getinfosbyvid(proxy, vid): dev.append(item["name"]) tags = [_["name"] for _ in js["results"][0]["tags"]] rates = [_["rating"] for _ in js["results"][0]["tags"]] + namemap = {} + try: + for r in js["results"][0]["va"]: + r = r["character"] + namemap[r["original"]] = r["name"] + except: + pass return dict( + namemap=namemap, title=gettitlefromjs(js["results"][0]), img=js["results"][0]["image"]["url"], sc=imgs, @@ -122,42 +130,6 @@ def getinfosbyvid(proxy, vid): ) -def getcharnamemapbyid(proxy, vid): - js = safegetvndbjson( - proxy, - "character", - { - "filters": [ - "vn", - "=", - ["id", "=", vid], - ], - "fields": "name,original", - }, - ) - js2 = safegetvndbjson( - proxy, - "vn", - { - "filters": ["id", "=", vid], - "fields": "va.character.name,va.character.original", - }, - ) - namemap = {} - try: - for r in js2["results"][0]["va"]: - r = r["character"] - namemap[r["original"]] = r["name"] - except: - pass - try: - for r in js["results"]: - namemap[r["original"]] = r["name"] - except: - pass - return namemap - - @Singleton_close class vndbsettings(QDialog): @@ -392,10 +364,8 @@ class searcher(common): def searchfordata(self, _vid): vid = "v{}".format(_vid) infos = getinfosbyvid(self.proxy, vid) - - namemap2 = getcharnamemapbyid(self.proxy, vid) namemap = self.getcharsfromhtml(vid) - namemap.update(namemap2) + namemap.update(infos["namemap"]) img = [ self.dispatchdownloadtask(_)