-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfgourl.py
94 lines (69 loc) · 2.27 KB
/
fgourl.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import json
import binascii
import requests
import main
import CatAndMouseGame
import os
requests.urllib3.disable_warnings()
session = requests.Session()
session.verify = False
# ===== Game's parameters =====
app_ver_ = ""
data_ver_ = 0
date_ver_ = 0
ver_code_ = ""
asset_bundle_folder_ = ""
data_server_folder_crc_ = 0
server_addr_ = "https://game.fate-go.jp"
github_token_ = ""
github_name_ = ""
# ==== User Info ====
def set_latest_assets():
global \
app_ver_, \
data_ver_, \
date_ver_, \
asset_bundle_folder_, \
data_server_folder_crc_, \
ver_code_, \
server_addr_
region = main.fate_region
# Set Game Server Depends of region
if region == "NA":
server_addr_ = "https://game.fate-go.us"
# Get Latest Version of the data!
version_str = main.get_latest_appver()
# main.logger.info(f"vv{version_str}")
response = requests.get(server_addr_ + "/gamedata/top?appVer=" + version_str).text
response_data = json.loads(response)["response"][0]["success"]
# Set AppVer, DataVer, DateVer
app_ver_ = version_str
data_ver_ = response_data["dataVer"]
date_ver_ = response_data["dateVer"]
ver_code_ = main.get_latest_verCode()
# main.logger.info(f"ver{ver_code_}")
# Use Asset Bundle Extractor to get Folder Name
assetbundle = CatAndMouseGame.getAssetBundle(response_data["assetbundle"])
get_folder_data(assetbundle)
def get_folder_data(assetbundle):
global asset_bundle_folder_, data_server_folder_crc_
asset_bundle_folder_ = assetbundle["folderName"]
data_server_folder_crc_ = binascii.crc32(assetbundle["folderName"].encode("utf8"))
# ===== End =====
user_agent_2 = os.environ.get("USER_AGENT_SECRET_2")
httpheader = {
"User-Agent": user_agent_2,
"Accept-Encoding": "deflate, gzip",
"Content-Type": "application/x-www-form-urlencoded",
"X-Unity-Version": "2022.3.28f1",
}
def NewSession():
return requests.Session()
def PostReq(s, url, data):
res = s.post(url, data=data, headers=httpheader, verify=False).json()
res_code = res["response"][0]["resCode"]
if res_code != "00":
detail = res["response"][0]["fail"]["detail"]
message = f"[ErrorCode: {res_code}]\n{detail}"
raise Exception(message)
return res