Skip to content

Commit e63731b

Browse files
committed
test
1 parent 8747d3a commit e63731b

File tree

3 files changed

+75
-8
lines changed

3 files changed

+75
-8
lines changed

LunaTranslator/LunaTranslator/gui/setting_about.py

+73-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
versionchecktask = queue.Queue()
2020

2121

22-
def getvesionmethod():
22+
def getvesionmethod_github():
2323
try:
2424
headers = {
2525
"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.9",
@@ -42,6 +42,22 @@ def getvesionmethod():
4242
print_exc()
4343
return None
4444

45+
def getvesionmethod():
46+
try:
47+
res = requests.get(
48+
"https://lunatranslator.xyz/version",
49+
verify=False,
50+
#proxies=getproxy(("github", "versioncheck")),
51+
)
52+
print(res.text)
53+
res=res.json()
54+
# print(res)
55+
_version = res["version"]
56+
return _version, res
57+
except:
58+
print_exc()
59+
return None
60+
4561

4662
def doupdate():
4763
if not gobject.baseobject.update_avalable:
@@ -69,7 +85,59 @@ def updatemethod_checkalready(size, savep):
6985

7086

7187
@tryprint
72-
def updatemethod(_version, self):
88+
def updatemethod(info, self):
89+
90+
check_interrupt = lambda: not (
91+
globalconfig["autoupdate"] and versionchecktask.empty()
92+
)
93+
if platform.architecture()[0] == "64bit":
94+
bit = "64"
95+
elif platform.architecture()[0] == "32bit":
96+
bit = "32"
97+
else:
98+
raise Exception
99+
url = info[bit]
100+
101+
savep = gobject.getcachedir("update/LunaTranslator{}.zip".format(bit))
102+
103+
r2 = requests.get(
104+
url, stream=True, verify=False, proxies=getproxy(("github", "download"))
105+
)
106+
size = int(r2.headers["Content-Length"])
107+
if check_interrupt():
108+
return
109+
if updatemethod_checkalready(size, savep):
110+
return savep
111+
with open(savep, "wb") as file:
112+
sess = requests.session()
113+
r = sess.get(
114+
url, stream=True, verify=False, proxies=getproxy(("github", "download"))
115+
)
116+
file_size = 0
117+
for i in r.iter_content(chunk_size=1024):
118+
if check_interrupt():
119+
return
120+
if not i:
121+
continue
122+
file.write(i)
123+
thislen = len(i)
124+
file_size += thislen
125+
126+
prg = int(10000 * file_size / size)
127+
prg100 = prg / 100
128+
sz = int(1000 * (int(size / 1024) / 1024)) / 1000
129+
self.progresssignal.emit(
130+
"总大小{} MB 进度 {:0.2f}% ".format(sz, prg100), prg
131+
)
132+
133+
if check_interrupt():
134+
return
135+
if updatemethod_checkalready(size, savep):
136+
return savep
137+
138+
139+
@tryprint
140+
def updatemethod_github(_version, self):
73141

74142
check_interrupt = lambda: not (
75143
globalconfig["autoupdate"] and versionchecktask.empty()
@@ -121,7 +189,6 @@ def updatemethod(_version, self):
121189
if updatemethod_checkalready(size, savep):
122190
return savep
123191

124-
125192
def uncompress(self, savep):
126193
self.progresssignal.emit("正在解压……", 10000)
127194
shutil.rmtree(gobject.getcachedir("update/LunaTranslator/"))
@@ -144,7 +211,7 @@ def versioncheckthread(self):
144211
if _version is None:
145212
sversion = _TR("获取失败")
146213
else:
147-
sversion = _version
214+
sversion,info = _version
148215
self.versiontextsignal.emit(sversion)
149216
version = winsharedutils.queryversion(sys.argv[0])
150217
need = (
@@ -154,7 +221,7 @@ def versioncheckthread(self):
154221
)
155222
if not (need and globalconfig["autoupdate"]):
156223
continue
157-
savep = updatemethod(_version, self)
224+
savep = updatemethod(info, self)
158225
if not savep:
159226
self.progresssignal.emit("自动更新失败,请手动更新", 0)
160227
continue
@@ -317,7 +384,7 @@ def setTab_update(self, basel):
317384
]
318385

319386
shuominggrid = [
320-
["Github", makehtml("https://github.com/HIllya51/LunaTranslator")],
387+
#["Github", makehtml("https://github.com/HIllya51/LunaTranslator")],
321388
["项目网站", makehtml("https://lunatranslator.xyz/")],
322389
[
323390
"使用说明",

LunaTranslator/LunaTranslator/gui/setting_textinput.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def gethookgrid(self):
5656
[
5757
(
5858
makehtml(
59-
"https://github.com/HIllya51/LunaHook/issues/new?assignees=&labels=enhancement&projects=&template=01_game_request.yaml",
59+
"https://lunatranslator.xyz/",
6060
show=_TR("不支持的游戏?"),
6161
),
6262
0,

plugins/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ include(generate_product_version)
2929

3030
set(VERSION_MAJOR 5)
3131
set(VERSION_MINOR 7)
32-
set(VERSION_PATCH 0)
32+
set(VERSION_PATCH 1)
3333

3434
add_library(pch pch.cpp)
3535
target_precompile_headers(pch PUBLIC pch.h)

0 commit comments

Comments
 (0)