Created
December 12, 2019 15:19
-
-
Save mvolfik/ca37bc64d73529800c0e4999e68df82f to your computer and use it in GitHub Desktop.
View timestamps when people solved specific task of Advent of Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from datetime import datetime as dt | |
import requests | |
import re | |
y = input("YEAR: ") | |
cookie = {'session': "YOUR SESSION COOKIE HERE (it's valid for 30 days)"} | |
homepage = requests.get('https://adventofcode.com/'+y+'/leaderboard/private', cookies=cookie) | |
for id in re.compile(r"(?<=\/"+y+r"\/leaderboard\/private\/view\/)(\d+)").findall(homepage.content.decode()): | |
print("\n"*5) | |
data = json.loads(requests.get('https://adventofcode.com/'+y+'/leaderboard/private/view/'+id+'.json', cookies=cookie).content) | |
i = 1 | |
while True: | |
j = 1 | |
while True: | |
tmp = {} | |
for m in data['members'].values(): | |
try: | |
key = m['name'] if m['name'] is not None else m['id'] | |
tmp[key] = dt.utcfromtimestamp(int(m['completion_day_level'][str(i)][str(j)]['get_star_ts'])) | |
except: pass | |
if tmp: | |
print("Day {0:>2}, part {1}:".format(i,j)) | |
for n, d in sorted(tmp.items(), key = lambda d: d[1]): | |
print("{0:>25}: {1}".format(n, d)) | |
j+=1 | |
else: break | |
if j == 1: break | |
else: i+=1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment