Skip to content

Instantly share code, notes, and snippets.

@mvolfik
Created December 12, 2019 15:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mvolfik/ca37bc64d73529800c0e4999e68df82f to your computer and use it in GitHub Desktop.
Save mvolfik/ca37bc64d73529800c0e4999e68df82f to your computer and use it in GitHub Desktop.
View timestamps when people solved specific task of Advent of Code
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