forked from shirof1re/ODPY
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_config.py
57 lines (46 loc) · 1.71 KB
/
update_config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import requests
import json
with open("config/config.json") as f:
config = json.load(f)
for i, j, k, l in [
[
"version", "cn",
"ak-conf.hypergryph.com",
"https://ak-conf.hypergryph.com/config/prod/official/Android/version"
],
[
"versionGlobal", "global",
"ak-conf.arknights.global",
"https://ark-us-static-online.yo-star.com/assetbundle/official/Android/version"
]
]:
old_resVersion = config[i]["android"]["resVersion"]
old_clientVersion = config[i]["android"]["clientVersion"]
old_funcVer = config["networkConfig"][j]["content"]["funcVer"]
timeout = 30
try:
version = requests.get(
l, timeout=timeout
).json()
resVersion = version["resVersion"]
clientVersion = version["clientVersion"]
if resVersion != old_resVersion:
config[i]["android"]["resVersion"] = resVersion
if clientVersion != old_clientVersion:
config[i]["android"]["clientVersion"] = clientVersion
except Exception:
pass
try:
network_config = requests.get(
f"https://{k}/config/prod/official/network_config", timeout=timeout
).json()
content = json.loads(network_config["content"])
funcVer = content["funcVer"]
if funcVer != old_funcVer:
config["networkConfig"][j]["content"]["funcVer"] = funcVer
config["networkConfig"][j]["content"]["configs"][funcVer] = config["networkConfig"][j]["content"]["configs"][old_funcVer]
del config["networkConfig"][j]["content"]["configs"][old_funcVer]
except Exception:
pass
with open("config/config.json", "w") as f:
json.dump(config, f, indent=4)