python-ballchasing 0.4.0__py3-none-any.whl → 0.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ballchasing/api.py +109 -83
- ballchasing/constants.py +84 -81
- ballchasing/typed/deep_group.py +27 -27
- ballchasing/typed/deep_replay.py +16 -16
- ballchasing/typed/shared.py +33 -8
- ballchasing/util/__init__.py +4 -0
- ballchasing/util/dates.py +35 -0
- ballchasing/util/iterators.py +118 -0
- ballchasing/util/replays.py +185 -0
- ballchasing/{util.py → util/stats.py} +7 -30
- {python_ballchasing-0.4.0.dist-info → python_ballchasing-0.5.0.dist-info}/METADATA +6 -5
- python_ballchasing-0.5.0.dist-info/RECORD +24 -0
- {python_ballchasing-0.4.0.dist-info → python_ballchasing-0.5.0.dist-info}/WHEEL +1 -1
- scripts/get_maps.py +147 -0
- scripts/test_typed.py +53 -0
- python_ballchasing-0.4.0.dist-info/RECORD +0 -19
- {python_ballchasing-0.4.0.dist-info → python_ballchasing-0.5.0.dist-info}/licenses/LICENSE +0 -0
- {python_ballchasing-0.4.0.dist-info → python_ballchasing-0.5.0.dist-info}/top_level.txt +0 -0
ballchasing/api.py
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import time
|
|
3
|
+
from concurrent.futures import ThreadPoolExecutor
|
|
3
4
|
from datetime import datetime
|
|
4
5
|
from pathlib import Path
|
|
5
|
-
from typing import
|
|
6
|
+
from typing import BinaryIO, Iterator
|
|
6
7
|
from urllib.parse import parse_qs, urlparse
|
|
7
8
|
|
|
8
|
-
from requests import sessions, Response, ConnectionError
|
|
9
|
+
from requests import sessions, Response, ConnectionError
|
|
9
10
|
|
|
10
|
-
from ballchasing.constants import GroupSortBy, SortDir,
|
|
11
|
-
|
|
11
|
+
from ballchasing.constants import GroupSortBy, SortDir, AnySeason, AnyRank, AnyReplaySortBy, AnySortDir, \
|
|
12
|
+
AnyVisibility, AnyGroupSortBy, AnyPlayerIdentification, AnyTeamIdentification, AnyMatchResult, NoneOrMore
|
|
12
13
|
from ballchasing.typed import DeepReplay, ShallowReplay, DeepGroup, ShallowGroup
|
|
13
14
|
from .typed.shared import BaseGroup, BasicGroup
|
|
14
|
-
from .util import to_rfc3339
|
|
15
|
+
from .util.dates import to_rfc3339
|
|
16
|
+
from .util.iterators import deduplicate as deduplicator
|
|
17
|
+
from .util.stats import parse_replay_stats
|
|
15
18
|
|
|
16
19
|
DEFAULT_URL = "https://ballchasing.com/api"
|
|
17
20
|
|
|
@@ -25,11 +28,11 @@ class BallchasingApi:
|
|
|
25
28
|
self,
|
|
26
29
|
auth_key: str,
|
|
27
30
|
*,
|
|
28
|
-
sleep_time_on_rate_limit:
|
|
31
|
+
sleep_time_on_rate_limit: float | None = None,
|
|
29
32
|
print_on_rate_limit: bool = False,
|
|
30
|
-
base_url=None,
|
|
31
|
-
do_initial_ping=True,
|
|
32
|
-
typed=False,
|
|
33
|
+
base_url: str | None = None,
|
|
34
|
+
do_initial_ping: bool = True,
|
|
35
|
+
typed: bool = False,
|
|
33
36
|
):
|
|
34
37
|
"""
|
|
35
38
|
|
|
@@ -117,6 +120,8 @@ class BallchasingApi:
|
|
|
117
120
|
time.sleep(retry_after)
|
|
118
121
|
elif self.sleep_time_on_rate_limit:
|
|
119
122
|
time.sleep(self.sleep_time_on_rate_limit)
|
|
123
|
+
elif r.status_code == 504:
|
|
124
|
+
raise ConnectionError("Gateway Timeout. The server did not respond in time.")
|
|
120
125
|
else:
|
|
121
126
|
r.raise_for_status() # Raise an error for any other status code'
|
|
122
127
|
except ConnectionError as e:
|
|
@@ -141,56 +146,68 @@ class BallchasingApi:
|
|
|
141
146
|
self._ping_result = result
|
|
142
147
|
return result
|
|
143
148
|
|
|
144
|
-
def _iterable_from_request(self, url, params):
|
|
145
|
-
# Shared by get_replays and get_groups
|
|
149
|
+
def _iterable_from_request(self, url, params, prefetch=True):
|
|
150
|
+
# Shared by get_replays and get_groups.
|
|
151
|
+
# When prefetch=True, the next page is requested in a background
|
|
152
|
+
# thread *before* yielding, so network I/O overlaps with the
|
|
153
|
+
# consumer processing items. When prefetch=False (e.g. deep mode
|
|
154
|
+
# where the consumer also makes API calls), the next request is
|
|
155
|
+
# submitted *after* yielding to avoid doubling the request rate.
|
|
146
156
|
remaining = params["count"]
|
|
147
|
-
# return_length = True
|
|
148
|
-
while remaining > 0:
|
|
149
|
-
request_count = min(remaining, 200)
|
|
150
|
-
params["count"] = request_count
|
|
151
|
-
try:
|
|
152
|
-
d = self._request(url, "GET", params=params).json()
|
|
153
|
-
except HTTPError as e:
|
|
154
|
-
if e.response.status_code == 504:
|
|
155
|
-
# Gateway Timeout, retry
|
|
156
|
-
time.sleep(5)
|
|
157
|
-
continue
|
|
158
157
|
|
|
159
|
-
|
|
160
|
-
|
|
158
|
+
def fetch_page(p):
|
|
159
|
+
return self._request(url, "GET", params=p).json()
|
|
160
|
+
|
|
161
|
+
with ThreadPoolExecutor(max_workers=1) as executor:
|
|
162
|
+
params["count"] = min(remaining, 200)
|
|
163
|
+
future = executor.submit(fetch_page, dict(params))
|
|
164
|
+
|
|
165
|
+
while remaining > 0:
|
|
166
|
+
d = future.result()
|
|
167
|
+
batch = d["list"][:min(remaining, 200)]
|
|
168
|
+
remaining -= len(batch)
|
|
169
|
+
|
|
170
|
+
has_next = "next" in d and remaining > 0
|
|
171
|
+
if has_next:
|
|
172
|
+
next_url = d["next"]
|
|
173
|
+
params["after"] = parse_qs(urlparse(next_url).query)["after"][0]
|
|
174
|
+
params["count"] = min(remaining, 200)
|
|
175
|
+
if prefetch:
|
|
176
|
+
future = executor.submit(fetch_page, dict(params))
|
|
161
177
|
|
|
162
|
-
|
|
163
|
-
break
|
|
178
|
+
yield from batch
|
|
164
179
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
180
|
+
if not has_next:
|
|
181
|
+
break
|
|
182
|
+
if not prefetch:
|
|
183
|
+
future = executor.submit(fetch_page, dict(params))
|
|
168
184
|
|
|
169
185
|
def get_replays(
|
|
170
186
|
self,
|
|
171
187
|
*,
|
|
172
|
-
title:
|
|
173
|
-
player_name:
|
|
174
|
-
player_id:
|
|
175
|
-
playlist:
|
|
176
|
-
season:
|
|
177
|
-
match_result:
|
|
178
|
-
min_rank:
|
|
179
|
-
max_rank:
|
|
180
|
-
pro:
|
|
181
|
-
uploader:
|
|
182
|
-
group_id:
|
|
183
|
-
map_id:
|
|
184
|
-
created_before:
|
|
185
|
-
created_after:
|
|
186
|
-
replay_after:
|
|
187
|
-
replay_before:
|
|
188
|
+
title: NoneOrMore[str] = None,
|
|
189
|
+
player_name: NoneOrMore[str] = None,
|
|
190
|
+
player_id: NoneOrMore[str] = None,
|
|
191
|
+
playlist: NoneOrMore[str] = None,
|
|
192
|
+
season: NoneOrMore[AnySeason] = None,
|
|
193
|
+
match_result: NoneOrMore[AnyMatchResult] = None,
|
|
194
|
+
min_rank: AnyRank | None = None,
|
|
195
|
+
max_rank: AnyRank | None = None,
|
|
196
|
+
pro: bool | None = None,
|
|
197
|
+
uploader: str | None = None,
|
|
198
|
+
group_id: NoneOrMore[str] = None,
|
|
199
|
+
map_id: NoneOrMore[str] = None,
|
|
200
|
+
created_before: str | datetime | None = None,
|
|
201
|
+
created_after: str | datetime | None = None,
|
|
202
|
+
replay_after: str | datetime | None = None,
|
|
203
|
+
replay_before: str | datetime | None = None,
|
|
188
204
|
count: int = 150,
|
|
189
|
-
sort_by:
|
|
205
|
+
sort_by: AnyReplaySortBy | None = None,
|
|
190
206
|
sort_dir: AnySortDir = SortDir.DESCENDING,
|
|
191
207
|
deep: bool = False,
|
|
192
|
-
typed:
|
|
193
|
-
|
|
208
|
+
typed: bool | None = None,
|
|
209
|
+
deduplicate: bool = False,
|
|
210
|
+
) -> Iterator[dict | ShallowReplay | DeepReplay]:
|
|
194
211
|
"""
|
|
195
212
|
This endpoint lets you filter and retrieve replays. The implementation returns an iterator.
|
|
196
213
|
|
|
@@ -224,12 +241,14 @@ class BallchasingApi:
|
|
|
224
241
|
:param sort_dir: sort direction
|
|
225
242
|
:param deep: whether to get full stats for each replay (will be much slower).
|
|
226
243
|
:param typed: whether to return a typed object (default is self.typed).
|
|
244
|
+
:param deduplicate: whether to deduplicate replays that seem to be the same game.
|
|
227
245
|
:return: an iterator over the replays returned by the API.
|
|
228
246
|
"""
|
|
229
247
|
url = f"{self.base_url}/replays"
|
|
230
248
|
params = {"title": title, "player-name": player_name, "player-id": player_id, "playlist": playlist,
|
|
231
249
|
"season": season, "match-result": match_result, "min-rank": min_rank, "max-rank": max_rank,
|
|
232
|
-
"pro": pro, "uploader": uploader, "group": group_id,
|
|
250
|
+
"pro": str(pro).lower() if isinstance(pro, bool) else pro, "uploader": uploader, "group": group_id,
|
|
251
|
+
"map": map_id,
|
|
233
252
|
"created-before": to_rfc3339(created_before), "created-after": to_rfc3339(created_after),
|
|
234
253
|
"replay-date-after": to_rfc3339(replay_after), "replay-date-before": to_rfc3339(replay_before),
|
|
235
254
|
"count": count, "sort-by": sort_by, "sort-dir": sort_dir}
|
|
@@ -237,14 +256,20 @@ class BallchasingApi:
|
|
|
237
256
|
if typed is None:
|
|
238
257
|
typed = self.typed
|
|
239
258
|
|
|
240
|
-
iterator = self._iterable_from_request(url, params)
|
|
259
|
+
iterator = self._iterable_from_request(url, params, prefetch=not deep)
|
|
241
260
|
if deep:
|
|
242
|
-
iterator = (self.get_replay(r["id"]
|
|
243
|
-
|
|
244
|
-
|
|
261
|
+
iterator = (self.get_replay(r["id"]) for r in iterator)
|
|
262
|
+
if deduplicate:
|
|
263
|
+
# Deep replays have match and replay IDs to deduplicate with. For shallow replays we check dates.
|
|
264
|
+
iterator = deduplicator(iterator, check_dates=not deep)
|
|
265
|
+
if typed:
|
|
266
|
+
if deep:
|
|
267
|
+
iterator = (DeepReplay(**r) for r in iterator)
|
|
268
|
+
else:
|
|
269
|
+
iterator = (ShallowReplay(**r) for r in iterator)
|
|
245
270
|
yield from iterator
|
|
246
271
|
|
|
247
|
-
def get_replay(self, replay_id: str, *, typed:
|
|
272
|
+
def get_replay(self, replay_id: str, *, typed: bool | None = None) -> dict | DeepReplay:
|
|
248
273
|
"""
|
|
249
274
|
Retrieve a given replay’s details and stats.
|
|
250
275
|
|
|
@@ -270,10 +295,10 @@ class BallchasingApi:
|
|
|
270
295
|
|
|
271
296
|
def upload_replay(
|
|
272
297
|
self,
|
|
273
|
-
replay_file:
|
|
298
|
+
replay_file: str | Path | BinaryIO,
|
|
274
299
|
*,
|
|
275
|
-
visibility:
|
|
276
|
-
group:
|
|
300
|
+
visibility: AnyVisibility | None = None,
|
|
301
|
+
group: str | None = None
|
|
277
302
|
) -> dict:
|
|
278
303
|
"""
|
|
279
304
|
Use this API to upload a replay file to ballchasing.com.
|
|
@@ -301,17 +326,17 @@ class BallchasingApi:
|
|
|
301
326
|
def get_groups(
|
|
302
327
|
self,
|
|
303
328
|
*,
|
|
304
|
-
name:
|
|
305
|
-
creator:
|
|
306
|
-
group:
|
|
307
|
-
created_before:
|
|
308
|
-
created_after:
|
|
329
|
+
name: str | None = None,
|
|
330
|
+
creator: str | None = None,
|
|
331
|
+
group: str | None = None,
|
|
332
|
+
created_before: str | datetime | None = None,
|
|
333
|
+
created_after: str | datetime | None = None,
|
|
309
334
|
count: int = 200,
|
|
310
335
|
sort_by: AnyGroupSortBy = GroupSortBy.CREATED,
|
|
311
336
|
sort_dir: AnySortDir = SortDir.DESCENDING,
|
|
312
337
|
deep: bool = False,
|
|
313
|
-
typed: bool = None,
|
|
314
|
-
) -> Iterator[
|
|
338
|
+
typed: bool | None = None,
|
|
339
|
+
) -> Iterator[dict | ShallowGroup | DeepGroup]:
|
|
315
340
|
"""
|
|
316
341
|
This endpoint lets you filter and retrieve replay groups.
|
|
317
342
|
|
|
@@ -334,7 +359,7 @@ class BallchasingApi:
|
|
|
334
359
|
url = f"{self.base_url}/groups/"
|
|
335
360
|
params = {"name": name, "creator": creator, "group": group, "created-before": to_rfc3339(created_before),
|
|
336
361
|
"created-after": to_rfc3339(created_after), "count": count, "sort-by": sort_by, "sort-dir": sort_dir}
|
|
337
|
-
iterator = self._iterable_from_request(url, params)
|
|
362
|
+
iterator = self._iterable_from_request(url, params, prefetch=not deep)
|
|
338
363
|
if typed is None:
|
|
339
364
|
typed = self.typed
|
|
340
365
|
if deep:
|
|
@@ -349,7 +374,7 @@ class BallchasingApi:
|
|
|
349
374
|
name: str,
|
|
350
375
|
player_identification: AnyPlayerIdentification,
|
|
351
376
|
team_identification: AnyTeamIdentification,
|
|
352
|
-
parent:
|
|
377
|
+
parent: str | None = None
|
|
353
378
|
) -> dict:
|
|
354
379
|
"""
|
|
355
380
|
Use this API to create a new replay group.
|
|
@@ -374,8 +399,8 @@ class BallchasingApi:
|
|
|
374
399
|
self,
|
|
375
400
|
group_id: str,
|
|
376
401
|
*,
|
|
377
|
-
typed:
|
|
378
|
-
) ->
|
|
402
|
+
typed: bool | None = None
|
|
403
|
+
) -> dict | DeepGroup:
|
|
379
404
|
"""
|
|
380
405
|
This endpoint retrieves a specific replay group info and stats given its id.
|
|
381
406
|
|
|
@@ -410,11 +435,11 @@ class BallchasingApi:
|
|
|
410
435
|
|
|
411
436
|
def get_group_replays(
|
|
412
437
|
self,
|
|
413
|
-
group:
|
|
438
|
+
group: str | dict | BasicGroup,
|
|
414
439
|
*,
|
|
415
440
|
deep: bool = False,
|
|
416
|
-
typed:
|
|
417
|
-
) -> Iterator[
|
|
441
|
+
typed: bool | None = None
|
|
442
|
+
) -> Iterator[dict | ShallowReplay | DeepReplay]:
|
|
418
443
|
"""
|
|
419
444
|
Finds all replays in a group, including child groups.
|
|
420
445
|
|
|
@@ -423,35 +448,36 @@ class BallchasingApi:
|
|
|
423
448
|
:param typed: whether to return a typed object (default is self.typed).
|
|
424
449
|
:return: an iterator over all the replays in the group.
|
|
425
450
|
"""
|
|
426
|
-
for path in self.get_group_tree(group, deep=deep, typed=typed):
|
|
427
|
-
group, replay = path
|
|
451
|
+
for path, replay in self.get_group_tree(group, deep=deep, typed=typed):
|
|
428
452
|
yield replay
|
|
429
453
|
|
|
430
454
|
def get_group_tree(
|
|
431
455
|
self,
|
|
432
|
-
group:
|
|
456
|
+
group: str | dict | BaseGroup,
|
|
433
457
|
*,
|
|
434
458
|
deep: bool = False,
|
|
435
|
-
typed:
|
|
436
|
-
):
|
|
459
|
+
typed: bool | None = None
|
|
460
|
+
) -> Iterator[tuple[list[str], dict | ShallowReplay | DeepReplay]]:
|
|
437
461
|
"""
|
|
438
|
-
Finds all replays in a group, and includes the
|
|
462
|
+
Finds all replays in a group, and includes the group path leading up to each replay.
|
|
463
|
+
|
|
439
464
|
:param group: the group id or a group dict.
|
|
440
465
|
:param deep: whether to get full stats for each replay and group (will be much slower).
|
|
441
466
|
:param typed: whether to return a typed object (default is self.typed).
|
|
467
|
+
:return: an iterator of (path, replay) tuples, where path is a list of group ids.
|
|
442
468
|
"""
|
|
443
469
|
if isinstance(group, str):
|
|
444
|
-
|
|
445
|
-
|
|
470
|
+
group_id = group
|
|
471
|
+
elif isinstance(group, BasicGroup):
|
|
446
472
|
group_id = group.id
|
|
447
473
|
else:
|
|
448
474
|
group_id = group["id"]
|
|
449
475
|
child_groups = self.get_groups(group=group_id, typed=typed)
|
|
450
476
|
for child in child_groups:
|
|
451
|
-
for path in self.get_group_tree(child, deep=deep, typed=typed):
|
|
452
|
-
yield group_id,
|
|
477
|
+
for path, replay in self.get_group_tree(child, deep=deep, typed=typed):
|
|
478
|
+
yield [group_id] + path, replay
|
|
453
479
|
for replay in self.get_replays(group_id=group_id, deep=deep, typed=typed):
|
|
454
|
-
yield group_id, replay
|
|
480
|
+
yield [group_id], replay
|
|
455
481
|
|
|
456
482
|
def download_replay(self, replay_id: str, path: str):
|
|
457
483
|
"""
|
|
@@ -494,7 +520,7 @@ class BallchasingApi:
|
|
|
494
520
|
res = self._request("/maps", "GET").json()
|
|
495
521
|
return res
|
|
496
522
|
|
|
497
|
-
def get_stats(self, replay:
|
|
523
|
+
def get_stats(self, replay: dict | str):
|
|
498
524
|
"""
|
|
499
525
|
Gets stats for players, teams and replay info.
|
|
500
526
|
|
ballchasing/constants.py
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
from typing import Literal, get_args,
|
|
2
|
-
|
|
3
|
-
AnyPlaylist = Union[
|
|
4
|
-
AnyStr,
|
|
5
|
-
Literal[
|
|
6
|
-
"unranked-duels", "unranked-doubles", "unranked-standard", "unranked-chaos",
|
|
7
|
-
"private", "season", "offline", "local-lobby",
|
|
8
|
-
"ranked-duels", "ranked-doubles", "ranked-solo-standard", "ranked-standard",
|
|
9
|
-
"snowday", "rocketlabs", "hoops", "rumble", "tournament", "dropshot",
|
|
10
|
-
"ranked-hoops", "ranked-rumble", "ranked-dropshot", "ranked-snowday",
|
|
11
|
-
"dropshot-rumble", "heatseeker", "gridiron", "spooky-cube"
|
|
12
|
-
]
|
|
13
|
-
]
|
|
1
|
+
from typing import Literal, get_args, TypeAlias, TypeVar, Sequence
|
|
14
2
|
|
|
15
3
|
|
|
16
4
|
def _get_literals(type_):
|
|
17
5
|
return get_args(get_args(type_)[1])
|
|
18
6
|
|
|
19
7
|
|
|
8
|
+
T = TypeVar('T')
|
|
9
|
+
OneOrMore: TypeAlias = T | Sequence[T]
|
|
10
|
+
NoneOrMore: TypeAlias = OneOrMore[T] | None
|
|
11
|
+
|
|
12
|
+
AnyPlaylist: TypeAlias = str | Literal[
|
|
13
|
+
"unranked-duels", "unranked-doubles", "unranked-standard", "unranked-chaos",
|
|
14
|
+
"private", "season", "offline", "local-lobby",
|
|
15
|
+
"ranked-duels", "ranked-doubles", "ranked-solo-standard", "ranked-standard",
|
|
16
|
+
"snowday", "rocketlabs", "hoops", "rumble", "tournament", "dropshot",
|
|
17
|
+
"ranked-hoops", "ranked-rumble", "ranked-dropshot", "ranked-snowday",
|
|
18
|
+
"dropshot-rumble", "heatseeker", "gridiron", "spooky-cube"
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
|
|
20
22
|
class Playlist:
|
|
21
23
|
ALL = (UNRANKED_DUELS, UNRANKED_DOUBLES, UNRANKED_STANDARD, UNRANKED_CHAOS, PRIVATE, SEASON, OFFLINE, LOCAL_LOBBY,
|
|
22
24
|
RANKED_DUELS, RANKED_DOUBLES, RANKED_SOLO_STANDARD, RANKED_STANDARD, SNOWDAY, ROCKETLABS, HOOPS, RUMBLE,
|
|
@@ -31,20 +33,17 @@ class Playlist:
|
|
|
31
33
|
MISC = (PRIVATE, SEASON, OFFLINE, LOCAL_LOBBY)
|
|
32
34
|
|
|
33
35
|
|
|
34
|
-
AnyRank =
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"grand-champion-1", "grand-champion-2", "grand-champion-3",
|
|
46
|
-
"supersonic-legend"
|
|
47
|
-
],
|
|
36
|
+
AnyRank: TypeAlias = str | Literal[
|
|
37
|
+
"unranked",
|
|
38
|
+
"bronze-1", "bronze-2", "bronze-3",
|
|
39
|
+
"silver-1", "silver-2", "silver-3",
|
|
40
|
+
"gold-1", "gold-2", "gold-3",
|
|
41
|
+
"platinum-1", "platinum-2", "platinum-3",
|
|
42
|
+
"diamond-1", "diamond-2", "diamond-3",
|
|
43
|
+
"champion-1", "champion-2", "champion-3",
|
|
44
|
+
"grand-champion", # Legacy. Seems to be interchangeable with "grand-champion-1"
|
|
45
|
+
"grand-champion-1", "grand-champion-2", "grand-champion-3",
|
|
46
|
+
"supersonic-legend"
|
|
48
47
|
]
|
|
49
48
|
|
|
50
49
|
|
|
@@ -70,13 +69,11 @@ class Rank:
|
|
|
70
69
|
GRAND_CHAMPION = (GRAND_CHAMPION_1, GRAND_CHAMPION_2, GRAND_CHAMPION_3)
|
|
71
70
|
|
|
72
71
|
|
|
73
|
-
AnySeason =
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
"f10", "f11", "f12", "f13", "f14", "f15", "f16", "f17", "f18", "f19"
|
|
79
|
-
]
|
|
72
|
+
AnySeason: TypeAlias = str | Literal[
|
|
73
|
+
"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14",
|
|
74
|
+
"f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9",
|
|
75
|
+
"f10", "f11", "f12", "f13", "f14", "f15", "f16", "f17", "f18", "f19",
|
|
76
|
+
"f20", "f21", "f22"
|
|
80
77
|
]
|
|
81
78
|
|
|
82
79
|
|
|
@@ -87,79 +84,81 @@ class Season:
|
|
|
87
84
|
SEASON_13_LEGACY, SEASON_14_LEGACY,
|
|
88
85
|
SEASON_1_FTP, SEASON_2_FTP, SEASON_3_FTP, SEASON_4_FTP, SEASON_5_FTP, SEASON_6_FTP, SEASON_7_FTP,
|
|
89
86
|
SEASON_8_FTP, SEASON_9_FTP, SEASON_10_FTP, SEASON_11_FTP, SEASON_12_FTP, SEASON_13_FTP, SEASON_14_FTP,
|
|
90
|
-
SEASON_15_FTP, SEASON_16_FTP, SEASON_17_FTP, SEASON_18_FTP, SEASON_19_FTP
|
|
87
|
+
SEASON_15_FTP, SEASON_16_FTP, SEASON_17_FTP, SEASON_18_FTP, SEASON_19_FTP, SEASON_20_FTP, SEASON_21_FTP,
|
|
88
|
+
SEASON_22_FTP
|
|
91
89
|
) = _get_literals(AnySeason)
|
|
92
90
|
LEGACY = ALL[:14]
|
|
93
91
|
FREE_TO_PLAY = ALL[14:]
|
|
94
92
|
|
|
95
93
|
|
|
96
|
-
AnyMatchResult =
|
|
94
|
+
AnyMatchResult: TypeAlias = str | Literal["win", "loss"]
|
|
97
95
|
|
|
98
96
|
|
|
99
97
|
class MatchResult:
|
|
100
98
|
WIN, LOSS = _get_literals(AnyMatchResult)
|
|
101
99
|
|
|
102
100
|
|
|
103
|
-
AnyReplaySortBy =
|
|
101
|
+
AnyReplaySortBy: TypeAlias = str | Literal["replay-date", "upload-date"]
|
|
104
102
|
|
|
105
103
|
|
|
106
104
|
class ReplaySortBy:
|
|
107
105
|
REPLAY_DATE, UPLOAD_DATE = _get_literals(AnyReplaySortBy)
|
|
108
106
|
|
|
109
107
|
|
|
110
|
-
AnyGroupSortBy =
|
|
108
|
+
AnyGroupSortBy: TypeAlias = str | Literal["created", "name"]
|
|
111
109
|
|
|
112
110
|
|
|
113
111
|
class GroupSortBy:
|
|
114
112
|
CREATED, NAME = _get_literals(AnyGroupSortBy)
|
|
115
113
|
|
|
116
114
|
|
|
117
|
-
AnySortDir =
|
|
115
|
+
AnySortDir: TypeAlias = str | Literal["asc", "desc"]
|
|
118
116
|
|
|
119
117
|
|
|
120
118
|
class SortDir:
|
|
121
119
|
ASCENDING, DESCENDING = ASC, DESC = _get_literals(AnySortDir)
|
|
122
120
|
|
|
123
121
|
|
|
124
|
-
AnyVisibility =
|
|
122
|
+
AnyVisibility: TypeAlias = str | Literal["public", "unlisted", "private"]
|
|
125
123
|
|
|
126
124
|
|
|
127
125
|
class Visibility:
|
|
128
126
|
PUBLIC, UNLISTED, PRIVATE = _get_literals(AnyVisibility)
|
|
129
127
|
|
|
130
128
|
|
|
131
|
-
AnyPlayerIdentification =
|
|
129
|
+
AnyPlayerIdentification: TypeAlias = str | Literal["by-id", "by-name"]
|
|
132
130
|
|
|
133
131
|
|
|
134
132
|
class PlayerIdentification:
|
|
135
133
|
BY_ID, BY_NAME = _get_literals(AnyPlayerIdentification)
|
|
136
134
|
|
|
137
135
|
|
|
138
|
-
AnyTeamIdentification =
|
|
136
|
+
AnyTeamIdentification: TypeAlias = str | Literal["by-distinct-players", "by-player-clusters"]
|
|
139
137
|
|
|
140
138
|
|
|
141
139
|
class TeamIdentification:
|
|
142
140
|
BY_DISTINCT_PLAYERS, BY_PLAYER_CLUSTERS = _get_literals(AnyTeamIdentification)
|
|
143
141
|
|
|
144
142
|
|
|
145
|
-
AnyMap =
|
|
143
|
+
AnyMap: TypeAlias = str | Literal[
|
|
146
144
|
"arc_darc_p", "arc_p", "arc_standard_p", "bb_p", "beach_night_grs_p", "beach_night_p", "beach_p", "beachvolley",
|
|
147
145
|
"chn_stadium_day_p", "chn_stadium_p", "cs_day_p", "cs_hw_p", "cs_p", "eurostadium_dusk_p", "eurostadium_night_p",
|
|
148
146
|
"eurostadium_p", "eurostadium_rainy_p", "eurostadium_snownight_p", "farm_grs_p", "farm_hw_p", "farm_night_p",
|
|
149
147
|
"farm_p", "farm_upsidedown_p", "ff_dusk_p", "fni_stadium_p", "haunted_trainstation_p", "hoopsstadium_p",
|
|
150
|
-
"hoopsstreet_p", "ko_calavera_p", "ko_carbon_p", "ko_quadron_p", "
|
|
148
|
+
"hoopsstreet_p", "ko_calavera_p", "ko_carbon_p", "ko_quadron_p", "labs_4v4_arena15_blackout_p",
|
|
149
|
+
"labs_4v4_arena15_eurostadium_night_p", "labs_4v4_arena15_retro_p", "labs_basin_p", "labs_circlepillars_p",
|
|
151
150
|
"labs_corridor_p", "labs_cosmic_p", "labs_cosmic_v4_p", "labs_doublegoal_p", "labs_doublegoal_v2_p",
|
|
152
151
|
"labs_galleon_mast_p", "labs_galleon_p", "labs_holyfield_p", "labs_holyfield_space_p", "labs_octagon_02_p",
|
|
153
|
-
"labs_octagon_p", "labs_pillarglass_p", "labs_pillarheat_p", "labs_pillarwings_p",
|
|
154
|
-
"
|
|
155
|
-
"
|
|
156
|
-
"
|
|
157
|
-
"
|
|
158
|
-
"
|
|
159
|
-
"
|
|
160
|
-
"
|
|
161
|
-
"wasteland_s_p", "woods_night_p", "woods_p"
|
|
162
|
-
]
|
|
152
|
+
"labs_octagon_b2b_02_p", "labs_octagon_p", "labs_pillarglass_p", "labs_pillarheat_p", "labs_pillarwings_p",
|
|
153
|
+
"labs_underpass_p", "labs_underpass_v0_p", "labs_utopia_p", "mall_day_p", "music_p", "neotokyo_arcade_p",
|
|
154
|
+
"neotokyo_hax_p", "neotokyo_p", "neotokyo_standard_p", "neotokyo_toon_p", "outlaw_oasis_p", "outlaw_p",
|
|
155
|
+
"paname_dusk_p", "park_bman_p", "park_night_p", "park_p", "park_rainy_p", "park_snowy_p", "shattershot_p",
|
|
156
|
+
"stadium_10a_p", "stadium_day_p", "stadium_foggy_p", "stadium_p", "stadium_race_day_p", "stadium_winter_p",
|
|
157
|
+
"street_p", "swoosh_p", "throwbackhockey_p", "throwbackstadium_p", "trainstation_dawn_p", "trainstation_night_p",
|
|
158
|
+
"trainstation_p", "trainstation_spooky_p", "uf_day_p", "underwater_grs_p", "underwater_p", "utopiastadium_dusk_p",
|
|
159
|
+
"utopiastadium_lux_p", "utopiastadium_p", "utopiastadium_snow_p", "wasteland_grs_p", "wasteland_night_p",
|
|
160
|
+
"wasteland_night_s_p", "wasteland_p", "wasteland_s_p", "woods_night_p", "woods_p"
|
|
161
|
+
]
|
|
163
162
|
|
|
164
163
|
|
|
165
164
|
class Map:
|
|
@@ -168,17 +167,18 @@ class Map:
|
|
|
168
167
|
CHN_STADIUM_DAY_P, CHN_STADIUM_P, CS_DAY_P, CS_HW_P, CS_P, EUROSTADIUM_DUSK_P, EUROSTADIUM_NIGHT_P,
|
|
169
168
|
EUROSTADIUM_P, EUROSTADIUM_RAINY_P, EUROSTADIUM_SNOWNIGHT_P, FARM_GRS_P, FARM_HW_P, FARM_NIGHT_P, FARM_P,
|
|
170
169
|
FARM_UPSIDEDOWN_P, FF_DUSK_P, FNI_STADIUM_P, HAUNTED_TRAINSTATION_P, HOOPSSTADIUM_P, HOOPSSTREET_P,
|
|
171
|
-
KO_CALAVERA_P, KO_CARBON_P, KO_QUADRON_P,
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
170
|
+
KO_CALAVERA_P, KO_CARBON_P, KO_QUADRON_P, LABS_4V4_ARENA15_BLACKOUT_P, LABS_4V4_ARENA15_EUROSTADIUM_NIGHT_P,
|
|
171
|
+
LABS_4V4_ARENA15_RETRO_P, LABS_BASIN_P, LABS_CIRCLEPILLARS_P, LABS_CORRIDOR_P, LABS_COSMIC_P, LABS_COSMIC_V4_P,
|
|
172
|
+
LABS_DOUBLEGOAL_P, LABS_DOUBLEGOAL_V2_P, LABS_GALLEON_MAST_P, LABS_GALLEON_P, LABS_HOLYFIELD_P,
|
|
173
|
+
LABS_HOLYFIELD_SPACE_P, LABS_OCTAGON_02_P, LABS_OCTAGON_B2B_02_P, LABS_OCTAGON_P, LABS_PILLARGLASS_P,
|
|
174
|
+
LABS_PILLARHEAT_P, LABS_PILLARWINGS_P, LABS_UNDERPASS_P, LABS_UNDERPASS_V0_P, LABS_UTOPIA_P, MALL_DAY_P,
|
|
175
|
+
MUSIC_P, NEOTOKYO_ARCADE_P, NEOTOKYO_HAX_P, NEOTOKYO_P, NEOTOKYO_STANDARD_P, NEOTOKYO_TOON_P, OUTLAW_OASIS_P,
|
|
176
|
+
OUTLAW_P, PANAME_DUSK_P, PARK_BMAN_P, PARK_NIGHT_P, PARK_P, PARK_RAINY_P, PARK_SNOWY_P, SHATTERSHOT_P,
|
|
177
|
+
STADIUM_10A_P, STADIUM_DAY_P, STADIUM_FOGGY_P, STADIUM_P, STADIUM_RACE_DAY_P, STADIUM_WINTER_P, STREET_P,
|
|
178
|
+
SWOOSH_P, THROWBACKHOCKEY_P, THROWBACKSTADIUM_P, TRAINSTATION_DAWN_P, TRAINSTATION_NIGHT_P, TRAINSTATION_P,
|
|
179
|
+
TRAINSTATION_SPOOKY_P, UF_DAY_P, UNDERWATER_GRS_P, UNDERWATER_P, UTOPIASTADIUM_DUSK_P, UTOPIASTADIUM_LUX_P,
|
|
180
|
+
UTOPIASTADIUM_P, UTOPIASTADIUM_SNOW_P, WASTELAND_GRS_P, WASTELAND_NIGHT_P, WASTELAND_NIGHT_S_P, WASTELAND_P,
|
|
181
|
+
WASTELAND_S_P, WOODS_NIGHT_P, WOODS_P
|
|
182
182
|
) = _get_literals(AnyMap)
|
|
183
183
|
NAMES = (
|
|
184
184
|
"Starbase ARC (Aftermath)", "Starbase ARC", "Starbase ARC (Standard)", "Champions Field (NFL)",
|
|
@@ -187,12 +187,13 @@ class Map:
|
|
|
187
187
|
"Mannfield (Dusk)", "Mannfield (Night)", "Mannfield", "Mannfield (Stormy)", "Mannfield (Snowy)",
|
|
188
188
|
"Farmstead (Pitched)", "Farmstead (Spooky)", "Farmstead (Night)", "Farmstead", "Farmstead (The Upside Down)",
|
|
189
189
|
"Estadio Vida (Dusk)", "Forbidden Temple (Fire & Ice)", "Urban Central (Haunted)", "Dunk House",
|
|
190
|
-
"The Block (Dusk)", "Calavera", "Carbon", "Quadron", "
|
|
191
|
-
"
|
|
192
|
-
"
|
|
190
|
+
"The Block (Dusk)", "Calavera", "Carbon", "Quadron", "Midnight Metro (Quads)", "Mannfield (Quads)",
|
|
191
|
+
"Sunset Dunes (Quads)", "Basin", "Pillars", "Corridor", "Cosmic", "Cosmic", "Double Goal", "Double Goal",
|
|
192
|
+
"Galleon Retro", "Galleon", "Loophole", "Holyfield", "Octagon", "Roadblock", "Octagon", "Hourglass",
|
|
193
|
+
"Barricade", "Colossus", "Underpass", "Underpass", "Utopia Retro", "Boostfield Mall", "Neon Fields",
|
|
193
194
|
"Neo Tokyo (Arcade)", "Neo Tokyo (Hacked)", "Neo Tokyo", "Neo Tokyo (Standard)", "Neo Tokyo (Comic)",
|
|
194
|
-
"Deadeye Canyon (Oasis)", "Deadeye Canyon", "
|
|
195
|
-
"Beckwith Park", "Beckwith Park (Stormy)", "Beckwith Park (Snowy)", "Core 707",
|
|
195
|
+
"Deadeye Canyon (Oasis)", "Deadeye Canyon", "Parc De Paris", "Beckwith Park (Night)",
|
|
196
|
+
"Beckwith Park (Midnight)", "Beckwith Park", "Beckwith Park (Stormy)", "Beckwith Park (Snowy)", "Core 707",
|
|
196
197
|
"DFH Stadium (10th Anniversary)", "DFH Stadium (Day)", "DFH Stadium (Stormy)", "DFH Stadium",
|
|
197
198
|
"DFH Stadium (Circuit)", "DFH Stadium (Snowy)", "Sovereign Heights (Dusk)", "Champions Field (Nike FC)",
|
|
198
199
|
"Throwback Stadium (Snowy)", "Throwback Stadium", "Urban Central (Dawn)", "Urban Central (Night)",
|
|
@@ -205,19 +206,21 @@ class Map:
|
|
|
205
206
|
STANDARD_MAPS = (
|
|
206
207
|
ARC_DARC_P, ARC_STANDARD_P, BEACH_NIGHT_GRS_P, BEACH_NIGHT_P, BEACH_P, CHN_STADIUM_DAY_P, CHN_STADIUM_P,
|
|
207
208
|
CS_DAY_P, CS_HW_P, CS_P, EUROSTADIUM_DUSK_P, EUROSTADIUM_NIGHT_P, EUROSTADIUM_P, EUROSTADIUM_RAINY_P,
|
|
208
|
-
EUROSTADIUM_SNOWNIGHT_P, FARM_GRS_P, FARM_NIGHT_P, FARM_P, FARM_UPSIDEDOWN_P, FF_DUSK_P, FNI_STADIUM_P,
|
|
209
|
-
NEOTOKYO_ARCADE_P, NEOTOKYO_HAX_P, NEOTOKYO_STANDARD_P, OUTLAW_OASIS_P, OUTLAW_P,
|
|
210
|
-
PARK_RAINY_P, PARK_SNOWY_P, STADIUM_10A_P, STADIUM_DAY_P, STADIUM_FOGGY_P,
|
|
211
|
-
STADIUM_WINTER_P, STREET_P, TRAINSTATION_DAWN_P, TRAINSTATION_NIGHT_P,
|
|
212
|
-
UNDERWATER_GRS_P, UNDERWATER_P, UTOPIASTADIUM_DUSK_P, UTOPIASTADIUM_LUX_P,
|
|
213
|
-
UTOPIASTADIUM_SNOW_P, WASTELAND_GRS_P, WASTELAND_NIGHT_P, WASTELAND_NIGHT_S_P, WASTELAND_P,
|
|
214
|
-
WOODS_NIGHT_P, WOODS_P
|
|
209
|
+
EUROSTADIUM_SNOWNIGHT_P, FARM_GRS_P, FARM_NIGHT_P, FARM_P, FARM_UPSIDEDOWN_P, FF_DUSK_P, FNI_STADIUM_P,
|
|
210
|
+
MALL_DAY_P, MUSIC_P, NEOTOKYO_ARCADE_P, NEOTOKYO_HAX_P, NEOTOKYO_STANDARD_P, OUTLAW_OASIS_P, OUTLAW_P,
|
|
211
|
+
PANAME_DUSK_P, PARK_NIGHT_P, PARK_P, PARK_RAINY_P, PARK_SNOWY_P, STADIUM_10A_P, STADIUM_DAY_P, STADIUM_FOGGY_P,
|
|
212
|
+
STADIUM_P, STADIUM_RACE_DAY_P, STADIUM_WINTER_P, STREET_P, TRAINSTATION_DAWN_P, TRAINSTATION_NIGHT_P,
|
|
213
|
+
TRAINSTATION_P, UF_DAY_P, UNDERWATER_GRS_P, UNDERWATER_P, UTOPIASTADIUM_DUSK_P, UTOPIASTADIUM_LUX_P,
|
|
214
|
+
UTOPIASTADIUM_P, UTOPIASTADIUM_SNOW_P, WASTELAND_GRS_P, WASTELAND_NIGHT_P, WASTELAND_NIGHT_S_P, WASTELAND_P,
|
|
215
|
+
WASTELAND_S_P, WOODS_NIGHT_P, WOODS_P
|
|
215
216
|
)
|
|
216
217
|
NON_STANDARD_MAPS = (
|
|
217
218
|
ARC_P, BB_P, BEACHVOLLEY, FARM_HW_P, HAUNTED_TRAINSTATION_P, HOOPSSTADIUM_P, HOOPSSTREET_P, KO_CALAVERA_P,
|
|
218
|
-
KO_CARBON_P, KO_QUADRON_P,
|
|
219
|
+
KO_CARBON_P, KO_QUADRON_P, LABS_4V4_ARENA15_BLACKOUT_P, LABS_4V4_ARENA15_EUROSTADIUM_NIGHT_P,
|
|
220
|
+
LABS_4V4_ARENA15_RETRO_P, LABS_BASIN_P, LABS_CIRCLEPILLARS_P, LABS_CORRIDOR_P, LABS_COSMIC_P, LABS_COSMIC_V4_P,
|
|
219
221
|
LABS_DOUBLEGOAL_P, LABS_DOUBLEGOAL_V2_P, LABS_GALLEON_MAST_P, LABS_GALLEON_P, LABS_HOLYFIELD_P,
|
|
220
|
-
LABS_HOLYFIELD_SPACE_P, LABS_OCTAGON_02_P, LABS_OCTAGON_P, LABS_PILLARGLASS_P,
|
|
221
|
-
LABS_PILLARWINGS_P, LABS_UNDERPASS_P, LABS_UNDERPASS_V0_P, LABS_UTOPIA_P, NEOTOKYO_P,
|
|
222
|
-
PARK_BMAN_P, SHATTERSHOT_P, SWOOSH_P, THROWBACKHOCKEY_P, THROWBACKSTADIUM_P,
|
|
222
|
+
LABS_HOLYFIELD_SPACE_P, LABS_OCTAGON_02_P, LABS_OCTAGON_B2B_02_P, LABS_OCTAGON_P, LABS_PILLARGLASS_P,
|
|
223
|
+
LABS_PILLARHEAT_P, LABS_PILLARWINGS_P, LABS_UNDERPASS_P, LABS_UNDERPASS_V0_P, LABS_UTOPIA_P, NEOTOKYO_P,
|
|
224
|
+
NEOTOKYO_TOON_P, PARK_BMAN_P, SHATTERSHOT_P, SWOOSH_P, THROWBACKHOCKEY_P, THROWBACKSTADIUM_P,
|
|
225
|
+
TRAINSTATION_SPOOKY_P
|
|
223
226
|
)
|