Skip to content

Instantly share code, notes, and snippets.

@JJK96
Created May 21, 2020 10:19
Show Gist options
  • Save JJK96/95ee3189350e1b1eae0c9ec61f31273e to your computer and use it in GitHub Desktop.
Save JJK96/95ee3189350e1b1eae0c9ec61f31273e to your computer and use it in GitHub Desktop.
import requests
from collections import defaultdict
r = requests.get(url="https://korpershoek.me/srb2/highscores/api/highscores", verify=False)
data = r.json()
skins = defaultdict(int)
#three for first place, 2 for second, 1 for last, 0 otherwise
weights = {
1:15,
2:12,
3:10,
4:8,
5:7,
6:6,
7:5,
8:4,
9:3,
10:2,
11:1,
12:0
}
for map in data:
for place, skin in enumerate(map['skins']):
skins[skin['name']] += weights.get(place+1, 0)
for k, v in sorted(skins.items(), key=lambda x: x[1], reverse=True):
print(f"{k}: {v}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment