mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-29 00:24:13 +08:00
steam
This commit is contained in:
parent
a63f2a1cdd
commit
e9b80ced6a
@ -718,7 +718,7 @@ class dialog_setting_game_internal(QWidget):
|
|||||||
for key in globalconfig["metadata"]:
|
for key in globalconfig["metadata"]:
|
||||||
idname = globalconfig["metadata"][key]["target"]
|
idname = globalconfig["metadata"][key]["target"]
|
||||||
vndbid = QLineEdit(str(savehook_new_data[gameuid][idname]))
|
vndbid = QLineEdit(str(savehook_new_data[gameuid][idname]))
|
||||||
if globalconfig["metadata"][key]["idtype"] == 0:
|
if globalconfig["metadata"][key].get("idtype", 1) == 0:
|
||||||
vndbid.setValidator(QIntValidator())
|
vndbid.setValidator(QIntValidator())
|
||||||
vndbid.setSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Fixed)
|
vndbid.setSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Fixed)
|
||||||
|
|
||||||
@ -2880,10 +2880,17 @@ class dialog_savedgame_v3(QWidget):
|
|||||||
elif action == editname or action == addlist:
|
elif action == editname or action == addlist:
|
||||||
_dia = Prompt_dialog(
|
_dia = Prompt_dialog(
|
||||||
self,
|
self,
|
||||||
_TR("添加列表"),
|
_TR("修改名称" if action == editname else "添加列表"),
|
||||||
"",
|
"",
|
||||||
[
|
[
|
||||||
[_TR("名称"), ""],
|
[
|
||||||
|
_TR("名称"),
|
||||||
|
(
|
||||||
|
savegametaged[calculatetagidx(tagid)]["title"]
|
||||||
|
if action == editname
|
||||||
|
else ""
|
||||||
|
),
|
||||||
|
],
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
231
LunaTranslator/LunaTranslator/metadata/steam.py
Normal file
231
LunaTranslator/LunaTranslator/metadata/steam.py
Normal file
@ -0,0 +1,231 @@
|
|||||||
|
import requests, re
|
||||||
|
from myutils.utils import simplehtmlparser, simplehtmlparser_all
|
||||||
|
from metadata.abstract import common
|
||||||
|
from myutils.config import (
|
||||||
|
_TR,
|
||||||
|
savehook_new_data,
|
||||||
|
)
|
||||||
|
from myutils.utils import initanewitem, gamdidchangedtask
|
||||||
|
import functools
|
||||||
|
import time
|
||||||
|
from network.requests_common import NetWorkException
|
||||||
|
from qtsymbols import *
|
||||||
|
from gui.usefulwidget import getlineedit
|
||||||
|
from gui.dialog_savedgame import getreflist, getalistname
|
||||||
|
from myutils.wrapper import Singleton_close
|
||||||
|
|
||||||
|
|
||||||
|
@Singleton_close
|
||||||
|
class steamsettings(QDialog):
|
||||||
|
|
||||||
|
def querylist(self):
|
||||||
|
|
||||||
|
cookies = {"steamLoginSecure": self._ref.config["steamLoginSecure"]}
|
||||||
|
headers = {
|
||||||
|
"sec-ch-ua": '"Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"',
|
||||||
|
"Accept": "application/json, text/javascript, */*; q=0.01",
|
||||||
|
"X-Requested-With": "XMLHttpRequest",
|
||||||
|
"sec-ch-ua-mobile": "?0",
|
||||||
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36",
|
||||||
|
"sec-ch-ua-platform": '"Windows"',
|
||||||
|
}
|
||||||
|
pagei = 0
|
||||||
|
collect = []
|
||||||
|
while True:
|
||||||
|
params = {
|
||||||
|
"p": pagei,
|
||||||
|
"v": "1",
|
||||||
|
}
|
||||||
|
pagei += 1
|
||||||
|
|
||||||
|
response = requests.get(
|
||||||
|
f'https://store.steampowered.com/wishlist/profiles/{self._ref.config["userid"] }/wishlistdata/',
|
||||||
|
cookies=cookies,
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
if len(response.json()) == 0:
|
||||||
|
break
|
||||||
|
for k, v in response.json().items():
|
||||||
|
print(k)
|
||||||
|
print(v["name"])
|
||||||
|
collect.append([k, v["name"]])
|
||||||
|
return collect
|
||||||
|
|
||||||
|
def getalistname_download(self, uid):
|
||||||
|
|
||||||
|
reflist = getreflist(uid)
|
||||||
|
collectresults = self.querylist()
|
||||||
|
thislistvids = [
|
||||||
|
savehook_new_data[gameuid][self._ref.idname] for gameuid in reflist
|
||||||
|
]
|
||||||
|
collect = {}
|
||||||
|
for gameuid in savehook_new_data:
|
||||||
|
vid = savehook_new_data[gameuid][self._ref.idname]
|
||||||
|
collect[vid] = gameuid
|
||||||
|
|
||||||
|
for item in collectresults:
|
||||||
|
vid, title = item
|
||||||
|
if vid in thislistvids:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if vid in collect:
|
||||||
|
gameuid = collect[vid]
|
||||||
|
else:
|
||||||
|
gameuid = initanewitem(f"steam_{vid}_{time.time()}", title)
|
||||||
|
savehook_new_data[gameuid][self._ref.idname] = vid
|
||||||
|
gamdidchangedtask(self._ref.typename, self._ref.idname, gameuid)
|
||||||
|
reflist.insert(0, gameuid)
|
||||||
|
|
||||||
|
def __getalistname(self, callback, _):
|
||||||
|
getalistname(self, callback)
|
||||||
|
|
||||||
|
def __init__(self, parent, _ref: common, gameuid: str) -> None:
|
||||||
|
super().__init__(parent, Qt.WindowType.WindowCloseButtonHint)
|
||||||
|
self._ref = _ref
|
||||||
|
self.resize(QSize(800, 10))
|
||||||
|
self.setWindowTitle(self._ref.config_all["name"])
|
||||||
|
fl = QFormLayout(self)
|
||||||
|
fl.addRow("userid", getlineedit(_ref.config, "userid"))
|
||||||
|
fl.addRow("cookie:steamLoginSecure", getlineedit(_ref.config, "steamLoginSecure"))
|
||||||
|
|
||||||
|
btn = QPushButton(_TR("wishlist"))
|
||||||
|
btn.clicked.connect(
|
||||||
|
functools.partial(self.__getalistname, self.getalistname_download)
|
||||||
|
)
|
||||||
|
fl.addRow(btn)
|
||||||
|
self.show()
|
||||||
|
|
||||||
|
|
||||||
|
class searcher(common):
|
||||||
|
|
||||||
|
def querysettingwindow(self, parent, gameuid):
|
||||||
|
steamsettings(parent, self, gameuid)
|
||||||
|
|
||||||
|
def getidbytitle(self, title):
|
||||||
|
|
||||||
|
headers = {
|
||||||
|
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
|
||||||
|
"Accept-Language": "zh-CN,zh;q=0.9,ar;q=0.8,sq;q=0.7,ru;q=0.6",
|
||||||
|
"Cache-Control": "max-age=0",
|
||||||
|
"Connection": "keep-alive",
|
||||||
|
"Referer": "https://store.steampowered.com/app/1638230/_/",
|
||||||
|
"Sec-Fetch-Dest": "document",
|
||||||
|
"Sec-Fetch-Mode": "navigate",
|
||||||
|
"Sec-Fetch-Site": "same-origin",
|
||||||
|
"Sec-Fetch-User": "?1",
|
||||||
|
"Upgrade-Insecure-Requests": "1",
|
||||||
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36",
|
||||||
|
"sec-ch-ua": '"Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"',
|
||||||
|
"sec-ch-ua-mobile": "?0",
|
||||||
|
"sec-ch-ua-platform": '"Windows"',
|
||||||
|
}
|
||||||
|
|
||||||
|
params = {
|
||||||
|
"term": title,
|
||||||
|
}
|
||||||
|
|
||||||
|
response = requests.get(
|
||||||
|
"https://store.steampowered.com/search/",
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
proxies=self.proxy,
|
||||||
|
)
|
||||||
|
|
||||||
|
inner = simplehtmlparser(
|
||||||
|
response.text, "div", '<div class="col search_capsule">'
|
||||||
|
)
|
||||||
|
return int(re.search("steam/apps/(.*?)/", inner).groups()[0])
|
||||||
|
|
||||||
|
def refmainpage(self, _id):
|
||||||
|
return f"https://store.steampowered.com/app/{_id}/_/"
|
||||||
|
|
||||||
|
def searchfordata(self, _id):
|
||||||
|
print(self.refmainpage(_id))
|
||||||
|
|
||||||
|
headers = {
|
||||||
|
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
|
||||||
|
"Accept-Language": "zh-CN,zh;q=0.9,ar;q=0.8,sq;q=0.7,ru;q=0.6",
|
||||||
|
"Cache-Control": "max-age=0",
|
||||||
|
"Connection": "keep-alive",
|
||||||
|
"Sec-Fetch-Dest": "document",
|
||||||
|
"Sec-Fetch-Mode": "navigate",
|
||||||
|
"Sec-Fetch-Site": "cross-site",
|
||||||
|
"Sec-Fetch-User": "?1",
|
||||||
|
"Upgrade-Insecure-Requests": "1",
|
||||||
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36",
|
||||||
|
"sec-ch-ua": '"Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"',
|
||||||
|
"sec-ch-ua-mobile": "?0",
|
||||||
|
"sec-ch-ua-platform": '"Windows"',
|
||||||
|
}
|
||||||
|
|
||||||
|
html = requests.get(
|
||||||
|
self.refmainpage(_id),
|
||||||
|
headers=headers,
|
||||||
|
proxies=self.proxy,
|
||||||
|
cookies={"steamLoginSecure": self.config["steamLoginSecure"]},
|
||||||
|
).text
|
||||||
|
|
||||||
|
imgsshow = [
|
||||||
|
f"https://{_[0]}/store_item_assets/steam/apps/{_id}/{_[1]}"
|
||||||
|
for _ in re.findall(
|
||||||
|
f'"https://(.*?)/store_item_assets/steam/apps/{_id}/(.*?)"', html
|
||||||
|
)
|
||||||
|
]
|
||||||
|
__ = []
|
||||||
|
for _ in imgsshow:
|
||||||
|
if " " in _:
|
||||||
|
continue
|
||||||
|
_ = re.sub("\\.(\\d+)x(\\d+)", "", _)
|
||||||
|
_ = re.sub("\\?t=(\\d+)", "", _)
|
||||||
|
if _.lower().endswith(".gif"):
|
||||||
|
continue
|
||||||
|
__.append(_)
|
||||||
|
title = re.search(
|
||||||
|
'<div id="appHubAppName" class="apphub_AppName">(.*?)</div>', html
|
||||||
|
).groups()[0]
|
||||||
|
|
||||||
|
inner = simplehtmlparser(
|
||||||
|
html,
|
||||||
|
"div",
|
||||||
|
'<div id="genresAndManufacturer"',
|
||||||
|
)
|
||||||
|
|
||||||
|
tags = set(
|
||||||
|
[
|
||||||
|
_.replace(",", "").strip()
|
||||||
|
for _ in re.findall(
|
||||||
|
">(.*?)<", simplehtmlparser(inner, "span", "<span data-panel=")
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
tagsuser = simplehtmlparser(
|
||||||
|
html,
|
||||||
|
"div",
|
||||||
|
'<div data-panel="{"flow-children":"row"}" class="glance_tags popular_tags"',
|
||||||
|
)
|
||||||
|
|
||||||
|
tagsuser = set(
|
||||||
|
[_.replace(",", "").strip() for _ in re.findall(">([\\s\\S]*?)<", tagsuser)]
|
||||||
|
)
|
||||||
|
|
||||||
|
tagsall = tagsuser.union(tags)
|
||||||
|
for _ in ("", "+"):
|
||||||
|
if _ not in tagsall:
|
||||||
|
continue
|
||||||
|
tagsall.remove(_)
|
||||||
|
|
||||||
|
inners = simplehtmlparser_all(
|
||||||
|
html,
|
||||||
|
"div",
|
||||||
|
'<div class="dev_row">',
|
||||||
|
)
|
||||||
|
devp = set([re.search("(.*)>(.*?)</a>", __).groups()[1] for __ in inners])
|
||||||
|
return {
|
||||||
|
# "namemap": namemap,
|
||||||
|
"title": title,
|
||||||
|
"imagepath_all": [self.dispatchdownloadtask(_) for _ in __],
|
||||||
|
"webtags": list(tagsall),
|
||||||
|
"developers": list(devp),
|
||||||
|
}
|
@ -156,6 +156,7 @@ def getdefaultsavehook(gamepath, title=None):
|
|||||||
"bgmsid": 0,
|
"bgmsid": 0,
|
||||||
"dlsiteid": "RJ/VJXXXX",
|
"dlsiteid": "RJ/VJXXXX",
|
||||||
"fanzaid": "",
|
"fanzaid": "",
|
||||||
|
"steamid": 0,
|
||||||
"title": "",
|
"title": "",
|
||||||
# "imagepath": None, # 封面->imagepath_all[0]
|
# "imagepath": None, # 封面->imagepath_all[0]
|
||||||
# "imagepath_much2": [], # 截图->imagepath_all[1:]
|
# "imagepath_much2": [], # 截图->imagepath_all[1:]
|
||||||
|
@ -84,6 +84,19 @@ def simplehtmlparser(text, tag, sign):
|
|||||||
return inner
|
return inner
|
||||||
|
|
||||||
|
|
||||||
|
def simplehtmlparser_all(text, tag, sign):
|
||||||
|
inners = []
|
||||||
|
while True:
|
||||||
|
idx = text.find(sign)
|
||||||
|
if idx == -1:
|
||||||
|
break
|
||||||
|
text = text[idx:]
|
||||||
|
inner = findenclose(text, tag)
|
||||||
|
inners.append(inner.replace("\n", ""))
|
||||||
|
text = text[len(inners) :]
|
||||||
|
return inners
|
||||||
|
|
||||||
|
|
||||||
def nowisdark():
|
def nowisdark():
|
||||||
dl = globalconfig["darklight2"]
|
dl = globalconfig["darklight2"]
|
||||||
if dl == 1:
|
if dl == 1:
|
||||||
@ -206,7 +219,7 @@ def idtypecheck(key, idname, gameuid, vid):
|
|||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if globalconfig["metadata"][key]["idtype"] == 0:
|
if globalconfig["metadata"][key].get("idtype", 1) == 0:
|
||||||
try:
|
try:
|
||||||
vid = int(vid)
|
vid = int(vid)
|
||||||
except:
|
except:
|
||||||
|
@ -246,8 +246,7 @@
|
|||||||
"downloadtasks": [],
|
"downloadtasks": [],
|
||||||
"searchfordatatasks": [],
|
"searchfordatatasks": [],
|
||||||
"useproxy": true,
|
"useproxy": true,
|
||||||
"target": "dlsiteid",
|
"target": "dlsiteid"
|
||||||
"idtype": 1
|
|
||||||
},
|
},
|
||||||
"bangumi": {
|
"bangumi": {
|
||||||
"name": "bangumi",
|
"name": "bangumi",
|
||||||
@ -265,8 +264,18 @@
|
|||||||
"downloadtasks": [],
|
"downloadtasks": [],
|
||||||
"searchfordatatasks": [],
|
"searchfordatatasks": [],
|
||||||
"useproxy": true,
|
"useproxy": true,
|
||||||
"target": "fanzaid",
|
"target": "fanzaid"
|
||||||
"idtype": 1
|
},
|
||||||
|
"steam": {
|
||||||
|
"name": "steam",
|
||||||
|
"downloadtasks": [],
|
||||||
|
"searchfordatatasks": [],
|
||||||
|
"useproxy": true,
|
||||||
|
"target": "steamid",
|
||||||
|
"args": {
|
||||||
|
"userid": "",
|
||||||
|
"steamLoginSecure": ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relationlinks": [
|
"relationlinks": [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user