-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
executable file
·53 lines (42 loc) · 1.63 KB
/
cli.py
File metadata and controls
executable file
·53 lines (42 loc) · 1.63 KB
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
#!/usr/bin/env python3
"""CLI entrypoint to the API code."""
import argparse
from datetime import date, timedelta
from ballchasing import Ballchasing
import config
import stats
def rfc3339(day):
return day.isoformat() + 'T00:00:00+00:00'
SEASON2_START = date(2020, 12, 10)
today = date.today()
TIME_MAP = {
'all': date(2015, 7, 7),
'season': SEASON2_START,
'month': today - timedelta(days=30),
'week': today - timedelta(days=7),
'yesterday': today - timedelta(days=1),
'today': today,
}
TIME_MAP = {k: rfc3339(v) for k, v in TIME_MAP.items()}
PLAYLIST_OPTIONS = ['unranked-duels', 'unranked-doubles', 'unranked-standard',
'unranked-chaos', 'private', 'season', 'offline',
'ranked-duels', 'ranked-doubles', 'ranked-solo-standard',
'ranked-standard', 'snowday', 'rocketlabs', 'hoops',
'rumble', 'tournament', 'dropshot', 'ranked-hoops',
'ranked-rumble', 'ranked-dropshot', 'ranked-snowday',
'dropshot-rumble', 'heatseeker']
parser = argparse.ArgumentParser()
parser.add_argument('--since', choices=TIME_MAP.keys(), default='all',
help='how far back to gather replays')
parser.add_argument('--playlist', choices=PLAYLIST_OPTIONS,
default='ranked-standard',
help='which playlist to search through')
args = parser.parse_args()
ballchasing = Ballchasing(token=config.API_KEY)
replays = ballchasing.replays({
'uploader': 'me',
'playlist': args.playlist,
'count': 200,
'replay-date-after': TIME_MAP[args.since],
})
stats.win_percentage(replays)