-
Notifications
You must be signed in to change notification settings - Fork 1
/
source_code_v1.2.py
307 lines (288 loc) · 14.3 KB
/
source_code_v1.2.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
#(add option for all and main, including rank, cosmetics, and more in game_type (supported by api as "all" and "main"))
import webbrowser
import requests
import datetime
from tzlocal import get_localzone
local_timezone = get_localzone()
#gets the information for the correct api url
username = input("What is the Hive username you wish to receive information about? ")
game_type = input("Which game would you like your stats for? Available values: wars, dr, hide, sg, murder, sky, ctf, drop, ground, build, party, bridge, grav: ")
#gets the response from the api url
stats = requests.get(f"https://api.playhive.com/v0/game/all/{game_type}/{username}")
# Check if the API request was successful
if stats.status_code != 200:
print("Error: Unable to retrieve stats. Please check your username.")
exit()
# Check if the game type is invalid
if game_type not in ["wars", "dr", "hide", "sg", "murder", "sky", "ctf", "drop", "ground", "build", "party", "bridge", "grav"]:
print("Error: Invalid game selection.")
exit()
#if the game type is wars, parses the response and prints it in the terminal
if game_type == ("wars"):
xp = stats.json()["xp"]
print(f"xp: {xp}")
played = stats.json()["played"]
print(f"played: {played}")
victories = stats.json()["victories"]
print(f"victories: {victories}")
first_played = stats.json()["first_played"]
first_played_datetime = datetime.datetime.fromtimestamp(first_played, datetime.timezone.utc)
first_played_datetime_local = first_played_datetime.astimezone(local_timezone)
first_played_human_readable = first_played_datetime_local.strftime('%m-%d-%Y %I:%M:%S %p %Z')
print("First played:", first_played_human_readable)
final_kills = stats.json()["final_kills"]
print(f"final kills: {final_kills}")
kills = stats.json()["kills"]
print(f"kills: {kills}")
treasure_destroyed = stats.json()["treasure_destroyed"]
print(f"treasures destroyed: {treasure_destroyed}")
deaths = stats.json()["deaths"]
print(f"deaths: {deaths}")
#if the game type is dr, parses the response and prints it in the terminal
if game_type == ("dr"):
xp = stats.json()["xp"]
print(f"xp: {xp}")
played = stats.json()["played"]
print(f"played: {played}")
victories = stats.json()["victories"]
print(f"victories: {victories}")
first_played = stats.json()["first_played"]
first_played_datetime = datetime.datetime.fromtimestamp(first_played, datetime.timezone.utc)
first_played_datetime_local = first_played_datetime.astimezone(local_timezone)
first_played_human_readable = first_played_datetime_local.strftime('%m-%d-%Y %I:%M:%S %p %Z')
print("First played:", first_played_human_readable)
deaths = stats.json()["deaths"]
print(f"deaths: {deaths}")
checkpoints = stats.json()["checkpoints"]
print(f"checkpoints: {checkpoints}")
activated = stats.json()["activated"]
print(f"traps activated: {activated}")
kills = stats.json()["kills"]
print(f"kills: {kills}")
#if the game type is hide, parses the response and prints it in the terminal
if game_type == ("hide"):
xp = stats.json()["xp"]
print(f"xp: {xp}")
played = stats.json()["played"]
print(f"played: {played}")
victories = stats.json()["victories"]
print(f"victories: {victories}")
first_played = stats.json()["first_played"]
first_played_datetime = datetime.datetime.fromtimestamp(first_played, datetime.timezone.utc)
first_played_datetime_local = first_played_datetime.astimezone(local_timezone)
first_played_human_readable = first_played_datetime_local.strftime('%m-%d-%Y %I:%M:%S %p %Z')
print("First played:", first_played_human_readable)
deaths = stats.json()["deaths"]
print(f"deaths: {deaths}")
hider_kills = stats.json()["hider_kills"]
print(f"hider kills: {hider_kills}")
#if the game type is sg, parses the response and prints it in the terminal
if game_type == ("sg"):
xp = stats.json()["xp"]
print(f"xp: {xp}")
played = stats.json()["played"]
print(f"played: {played}")
victories = stats.json()["victories"]
print(f"victories: {victories}")
first_played = stats.json()["first_played"]
first_played_datetime = datetime.datetime.fromtimestamp(first_played, datetime.timezone.utc)
first_played_datetime_local = first_played_datetime.astimezone(local_timezone)
first_played_human_readable = first_played_datetime_local.strftime('%m-%d-%Y %I:%M:%S %p %Z')
print("First played:", first_played_human_readable)
crates = stats.json()["crates"]
print(f"crates opened: {crates}")
deathmatches = stats.json()["deathmatches"]
print(f"deathmatches reached: {deathmatches}")
cows = stats.json()["cows"]
print(f"cache cows: {cows}")
kills = stats.json()["kills"]
print(f"kills: {kills}")
deaths = stats.json()["deaths"]
print(f"deaths: {deaths}")
#if the game type is murder, parses the response and prints it in the terminal
if game_type == ("murder"):
xp = stats.json()["xp"]
print(f"xp: {xp}")
played = stats.json()["played"]
print(f"played: {played}")
victories = stats.json()["victories"]
print(f"victories: {victories}")
first_played = stats.json()["first_played"]
first_played_datetime = datetime.datetime.fromtimestamp(first_played, datetime.timezone.utc)
first_played_datetime_local = first_played_datetime.astimezone(local_timezone)
first_played_human_readable = first_played_datetime_local.strftime('%m-%d-%Y %I:%M:%S %p %Z')
print("First played:", first_played_human_readable)
deaths = stats.json()["deaths"]
print(f"deaths: {deaths}")
coins = stats.json()["coins"]
print(f"coins collected: {coins}")
murders = stats.json()["murders"]
print(f"murders: {murders}")
murderer_eliminations = stats.json()["murderer_eliminations"]
print(f"murderer eliminations: {murderer_eliminations}")
#if the game type is sky, parses the response and prints it in the terminal
if game_type == ("sky"):
xp = stats.json()["xp"]
print(f"xp: {xp}")
played = stats.json()["played"]
print(f"played: {played}")
victories = stats.json()["victories"]
print(f"victories: {victories}")
first_played = stats.json()["first_played"]
first_played_datetime = datetime.datetime.fromtimestamp(first_played, datetime.timezone.utc)
first_played_datetime_local = first_played_datetime.astimezone(local_timezone)
first_played_human_readable = first_played_datetime_local.strftime('%m-%d-%Y %I:%M:%S %p %Z')
print("First played:", first_played_human_readable)
kills = stats.json()["kills"]
print(f"kills: {kills}")
mystery_chests_destroyed = stats.json()["mystery_chests_destroyed"]
print(f"mystery chests destroyed: {mystery_chests_destroyed}")
ores_mined = stats.json()["ores_mined"]
print(f"ores mined: {ores_mined}")
spells_used = stats.json()["spells_used"]
print(f"spells used: {spells_used}")
deaths = stats.json()["deaths"]
print(f"deaths: {deaths}")
#if the game type is ctf, parses the response and prints it in the terminal
if game_type == ("ctf"):
xp = stats.json()["xp"]
print(f"xp: {xp}")
played = stats.json()["played"]
print(f"played: {played}")
victories = stats.json()["victories"]
print(f"victories: {victories}")
first_played = stats.json()["first_played"]
first_played_datetime = datetime.datetime.fromtimestamp(first_played, datetime.timezone.utc)
first_played_datetime_local = first_played_datetime.astimezone(local_timezone)
first_played_human_readable = first_played_datetime_local.strftime('%m-%d-%Y %I:%M:%S %p %Z')
print("First played:", first_played_human_readable)
assists = stats.json()["assists"]
print(f"assists: {assists}")
deaths = stats.json()["deaths"]
print(f"deaths: {deaths}")
flags_captured = stats.json()["flags_captured"]
print(f"flags captured: {flags_captured}")
kills = stats.json()["kills"]
print(f"kills: {kills}")
flags_returned = stats.json()["flags_returned"]
print(f"flags returned: {flags_returned}")
#if the game type is drop, parses the response and prints it in the terminal
if game_type == ("drop"):
xp = stats.json()["xp"]
print(f"xp: {xp}")
played = stats.json()["played"]
print(f"played: {played}")
victories = stats.json()["victories"]
print(f"victories: {victories}")
first_played = stats.json()["first_played"]
first_played_datetime = datetime.datetime.fromtimestamp(first_played, datetime.timezone.utc)
first_played_datetime_local = first_played_datetime.astimezone(local_timezone)
first_played_human_readable = first_played_datetime_local.strftime('%m-%d-%Y %I:%M:%S %p %Z')
print("First played:", first_played_human_readable)
blocks_destroyed = stats.json()["blocks_destroyed"]
print(f"blocks destroyed: {blocks_destroyed}")
powerups_collected = stats.json()["powerups_collected"]
print(f"powerups collected: {powerups_collected}")
vaults_used = stats.json()["vaults_used"]
print(f"vaults used: {vaults_used}")
deaths = stats.json()["deaths"]
print(f"deaths: {deaths}")
#if the game type is ground, parses the response and prints it in the terminal
if game_type == ("ground"):
xp = stats.json()["xp"]
print(f"xp: {xp}")
played = stats.json()["played"]
print(f"played: {played}")
victories = stats.json()["victories"]
print(f"victories: {victories}")
first_played = stats.json()["first_played"]
first_played_datetime = datetime.datetime.fromtimestamp(first_played, datetime.timezone.utc)
first_played_datetime_local = first_played_datetime.astimezone(local_timezone)
first_played_human_readable = first_played_datetime_local.strftime('%m-%d-%Y %I:%M:%S %p %Z')
print("First played:", first_played_human_readable)
blocks_destroyed = stats.json()["blocks_destroyed"]
print(f"blocks destroyed: {blocks_destroyed}")
blocks_placed = stats.json()["blocks_placed"]
print(f"blocks placed: {blocks_placed}")
deaths = stats.json()["deaths"]
print(f"deaths: {deaths}")
projectiles_fired = stats.json()["projectiles_fired"]
print(f"projectiles fired: {projectiles_fired}")
kills = stats.json()["kills"]
print(f"kills: {kills}")
#if the game type is build, parses the response and prints it in the terminal
if game_type == ("build"):
xp = stats.json()["xp"]
print(f"xp: {xp}")
played = stats.json()["played"]
print(f"played: {played}")
victories = stats.json()["victories"]
print(f"victories: {victories}")
first_played = stats.json()["first_played"]
first_played_datetime = datetime.datetime.fromtimestamp(first_played, datetime.timezone.utc)
first_played_datetime_local = first_played_datetime.astimezone(local_timezone)
first_played_human_readable = first_played_datetime_local.strftime('%m-%d-%Y %I:%M:%S %p %Z')
print("First played:", first_played_human_readable)
rating_good_received = stats.json()["rating_good_received"]
print(f"rating good received: {rating_good_received}")
rating_meh_received = stats.json()["rating_meh_received"]
print(f"rating meh received: {rating_meh_received}")
rating_okay_received = stats.json()["rating_okay_received"]
print(f"rating okay received: {rating_okay_received}")
rating_great_received = stats.json()["rating_great_received"]
print(f"rating great received: {rating_great_received}")
#if the game type is party, parses the response and prints it in the terminal
if game_type == ("party"):
xp = stats.json()["xp"]
print(f"xp: {xp}")
played = stats.json()["played"]
print(f"played: {played}")
victories = stats.json()["victories"]
print(f"victories: {victories}")
first_played = stats.json()["first_played"]
first_played_datetime = datetime.datetime.fromtimestamp(first_played, datetime.timezone.utc)
first_played_datetime_local = first_played_datetime.astimezone(local_timezone)
first_played_human_readable = first_played_datetime_local.strftime('%m-%d-%Y %I:%M:%S %p %Z')
print("First played:", first_played_human_readable)
powerups_collected = stats.json()["powerups_collected"]
print(f"powerups collected: {powerups_collected}")
rounds_survived = stats.json()["rounds_survived"]
print(f"rounds survived: {rounds_survived}")
#if the game type is bridge, parses the response and prints it in the terminal
if game_type == ("bridge"):
xp = stats.json()["xp"]
print(f"xp: {xp}")
played = stats.json()["played"]
print(f"played: {played}")
victories = stats.json()["victories"]
print(f"victories: {victories}")
first_played = stats.json()["first_played"]
first_played_datetime = datetime.datetime.fromtimestamp(first_played, datetime.timezone.utc)
first_played_datetime_local = first_played_datetime.astimezone(local_timezone)
first_played_human_readable = first_played_datetime_local.strftime('%m-%d-%Y %I:%M:%S %p %Z')
print("First played:", first_played_human_readable)
kills = stats.json()["kills"]
print(f"kills: {kills}")
deaths = stats.json()["deaths"]
print(f"deaths: {deaths}")
goals = stats.json()["goals"]
print(f"goals: {goals}")
#if the game type is grav, parses the response and prints it in the terminal
if game_type == ("grav"):
xp = stats.json()["xp"]
print(f"xp: {xp}")
played = stats.json()["played"]
print(f"played: {played}")
victories = stats.json()["victories"]
print(f"victories: {victories}")
first_played = stats.json()["first_played"]
first_played_datetime = datetime.datetime.fromtimestamp(first_played, datetime.timezone.utc)
first_played_datetime_local = first_played_datetime.astimezone(local_timezone)
first_played_human_readable = first_played_datetime_local.strftime('%m-%d-%Y %I:%M:%S %p %Z')
print("First played:", first_played_human_readable)
deaths = stats.json()["deaths"]
print(f"deaths: {deaths}")
maps_completed = stats.json()["maps_completed"]
print(f"maps completed: {maps_completed}")
maps_completed_without_dying = stats.json()["maps_completed_without_dying"]
print(f"maps completed without dying: {maps_completed_without_dying}")