-
Notifications
You must be signed in to change notification settings - Fork 0
/
leaderboards.py
26 lines (26 loc) · 1.07 KB
/
leaderboards.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
import requests
from pprint import pformat
import requests
from . import get_username
from . import InvalidAPIKey
def get_leaderboard(key=None):
from . import api_key
if key is None:
if api_key is None:
raise InvalidAPIKey('No API key specified')
key = api_key
data = requests.get(f'https://api.hypixel.net/leaderboards?key={key}').json()
return pformat({
'duels': {
'weekly_wins': [get_username(x) for x in data['leaderboards']['DUELS'][0]['leaders']],
'monthly_wins': [get_username(x) for x in data['leaderboards']['DUELS'][1]['leaders']],
},
'skywars': {
'levels': [get_username(x) for x in data['leaderboards']['SKYWARS'][0]['leaders']],
'wins': [get_username(x) for x in data['leaderboards']['SKYWARS'][2]['leaders']],
'kills': [get_username(x) for x in data['leaderboards']['SKYWARS'][3]['leaders']]
},
'bedwars': {
'levels': [get_username(x) for x in data['leaderboards']['BEDWARS'][0]['leaders']]
}
}, width=2, indent=4)