-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapi_manager.py
129 lines (110 loc) · 4.58 KB
/
api_manager.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import requests
class ApiManager:
def __init__(self, bearer_token):
self.request_id = 638586594713428736
self.bearer_token = bearer_token
self.body_hmac = (
"H53bD3fYs0UvGqpF5bFXDiBYsx85uaCGoII0U579GBc=" # HMAC is a fixed value
)
def update_bearer_token(self):
new_token = input(
"Bearer token has expired or is invalid. Please enter a new bearer token: "
)
self.bearer_token = new_token
def get_battlefields(self):
url = "https://gv.gameduo.net/battlefield/getAllRegions"
headers = {
"Authorization": f"Bearer {self.bearer_token}",
"bodyhmac": self.body_hmac,
"Content-Type": "application/json",
"Host": "gv.gameduo.net",
"request-id": str(self.request_id),
"User-Agent": "UnityPlayer/2021.3.33f1 (UnityWebRequest/1.0, libcurl/8.4.0-DEV)",
"X-Unity-Version": "2021.3.33f1",
"Content-Length": "2",
}
response = requests.post(url, headers=headers, json={})
if response.status_code == 403:
self.update_bearer_token()
return self.get_battlefields()
self.request_id += 1
#print (response)
return response.json()
def get_world_battlefields(self):
url = "https://gv.gameduo.net/world-battlefield/get-all-regions"
headers = {
"Authorization": f"Bearer {self.bearer_token}",
"bodyhmac": self.body_hmac,
"Content-Type": "application/json",
"Host": "gv.gameduo.net",
"request-id": str(self.request_id),
"User-Agent": "UnityPlayer/2021.3.33f1 (UnityWebRequest/1.0, libcurl/8.4.0-DEV)",
"X-Unity-Version": "2021.3.33f1",
"Content-Length": "2",
}
response = requests.post(url, headers=headers, json={})
if response.status_code == 403:
self.update_bearer_token()
return self.get_world_battlefields()
self.request_id += 1
# print(response.json)
return response.json()
def get_upper_battlefield(self):
url = "https://gv.gameduo.net/abyss-battlefield/get-all-regions"
headers = {
"Authorization": f"Bearer {self.bearer_token}",
"bodyhmac": "YElhfvjY6RTZB6c2cxbC974O+Sfp9809TetmoTEKdRU=",
"Content-Type": "application/json",
"Host": "gv.gameduo.net",
"request-id": str(self.request_id),
"User-Agent": "UnityPlayer/2021.3.33f1 (UnityWebRequest/1.0, libcurl/8.4.0-DEV)",
"X-Unity-Version": "2021.3.33f1",
"Content-Length": "11",
}
body = {
"floor": 1
}
response = requests.post(url, headers=headers, json=body)
#print(response.json())
if response.status_code == 403:
self.update_bearer_token()
return self.get_upper_battlefield()
self.request_id += 1
return response.json()
def get_siege_data(self):
url = "https://gv.gameduo.net/guild-domination-mode/load-all-territories"
headers = {
"Authorization": f"Bearer {self.bearer_token}",
"bodyhmac": self.body_hmac,
"Content-Type": "application/json",
"Host": "gv.gameduo.net",
"request-id": str(self.request_id),
"User-Agent": "UnityPlayer/2021.3.33f1 (UnityWebRequest/1.0, libcurl/8.4.0-DEV)",
"X-Unity-Version": "2021.3.33f1",
"Content-Length": "2",
}
response = requests.post(url, headers=headers, json={})
if response.status_code == 403:
self.update_bearer_token()
return self.get_battlefields()
self.request_id += 1
print (response)
return response.json()
def get_node_detail(self, node_id, node_hmac):
url = "https://gv.gameduo.net/guild-domination-mode/get-detail"
headers = {
"Authorization": f"Bearer {self.bearer_token}",
"bodyhmac": node_hmac,
"Content-Type": "application/json",
"Host": "gv.gameduo.net",
"request-id": str(self.request_id),
"User-Agent": "UnityPlayer/2021.3.33f1 (UnityWebRequest/1.0, libcurl/8.4.0-DEV)",
"Content-Length": "23",
}
body = {"territoryId": node_id}
response = requests.post(url, headers=headers, json=body)
if response.status_code == 403:
self.update_bearer_token()
return self.get_node_detail(node_hmac)
self.request_id += 1
return response.json()