This commit is contained in:
恍兮惚兮 2024-09-16 15:50:02 +08:00
parent 96e41bd3b5
commit d01f204afb
2 changed files with 45 additions and 8 deletions

View File

@ -121,6 +121,18 @@ def getinfosbyvid(proxy, vid):
def getcharnamemapbyid(proxy, vid): def getcharnamemapbyid(proxy, vid):
js = safegetvndbjson( js = safegetvndbjson(
proxy,
"character",
{
"filters": [
"vn",
"=",
["id", "=", vid],
],
"fields": "name,original",
},
)
js2 = safegetvndbjson(
proxy, proxy,
"vn", "vn",
{ {
@ -128,18 +140,18 @@ def getcharnamemapbyid(proxy, vid):
"fields": "va.character.name,va.character.original", "fields": "va.character.name,va.character.original",
}, },
) )
print(js)
if js:
res = js["results"][0]["va"]
else:
return {}
namemap = {} namemap = {}
try: try:
for r in res: for r in js2["results"][0]["va"]:
r = r["character"] r = r["character"]
namemap[r["original"]] = r["name"] namemap[r["original"]] = r["name"]
except: except:
pass pass
try:
for r in js["results"]:
namemap[r["original"]] = r["name"]
except:
pass
return namemap return namemap
@ -352,6 +364,29 @@ class searcher(common):
else: else:
return [] return []
def getcharsfromhtml(self, _vid):
headers = {
"sec-ch-ua": '"Microsoft Edge";v="113", "Chromium";v="113", "Not-A.Brand";v="24"',
"Referer": "https://vndb.org/",
"sec-ch-ua-mobile": "?0",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Edg/113.0.1774.42",
"sec-ch-ua-platform": '"Windows"',
}
html = self.proxysession.get(
f"https://vndb.org/{_vid}/chars", headers=headers
).text
find = re.findall(
'<tr><td colspan="2"><a href="/c(.*?)>(.*?)</a><small(.*?)>(.*?)</small>',
html,
)
namemap = {}
for _, en, _, ja in find:
namemap[ja] = en
return namemap
def getreleasecvfromhtml(self, _vid): def getreleasecvfromhtml(self, _vid):
headers = { headers = {
@ -375,7 +410,9 @@ class searcher(common):
infos = getinfosbyvid(self.proxy, vid) infos = getinfosbyvid(self.proxy, vid)
title = infos["title"] title = infos["title"]
namemap = getcharnamemapbyid(self.proxy, vid) namemap2 = getcharnamemapbyid(self.proxy, vid)
namemap = self.getcharsfromhtml(vid)
namemap.update(namemap2)
vndbtags = self.gettagfromhtml(_vid) vndbtags = self.gettagfromhtml(_vid)
developers = infos["dev"] developers = infos["dev"]

View File

@ -29,7 +29,7 @@ include(generate_product_version)
set(VERSION_MAJOR 5) set(VERSION_MAJOR 5)
set(VERSION_MINOR 36) set(VERSION_MINOR 36)
set(VERSION_PATCH 1) set(VERSION_PATCH 2)
add_library(pch pch.cpp) add_library(pch pch.cpp)
target_precompile_headers(pch PUBLIC pch.h) target_precompile_headers(pch PUBLIC pch.h)