-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstats.py
30 lines (22 loc) · 811 Bytes
/
stats.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
import sys
from datetime import datetime
import requests
with open('.sessioncookie', 'r') as f:
session_token = f.read().strip()
member_id = "1194494"
url = "https://adventofcode.com/2023/leaderboard/private/view/3418645.json"
headers = {"Cookie": "session=" + session_token}
data = None
if (r := requests.get(url, headers=headers)).status_code == 200:
data = r.json()
else:
sys.exit(f"Response {r.status_code}: {r.reason} \n{r.content}")
me = data["members"][member_id]
print("My Stats:")
for key in sorted(me["completion_day_level"]):
print(f"\tDay {key}:")
for star in sorted(me["completion_day_level"][key]):
star_time = datetime.fromtimestamp(
me["completion_day_level"][key][star]["get_star_ts"]
)
print(f"\t\tStar {star} Time: {star_time}")