-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer_count.py
47 lines (44 loc) · 2.24 KB
/
player_count.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import requests
import aiohttp
import asyncio
import pprint
from .auction import InvalidAPIKey
def get_online_players(key=None, detailed: bool=False):
from . import api_key
if api_key is None:
if key is None:
raise InvalidAPIKey('NoApiKey')
elif key is None:
key = api_key
if detailed:
data = requests.get(f'https://api.hypixel.net/counts?key={key}').json()
return pprint.pformat({'lobby': int(data['games']['MAIN_LOBBY']['players']),
'tournament_lobby': int(data['games']['TOURNAMENT_LOBBY']['players']),
'smp': int(data['games']['SMP']['players']),
'bedwars': int(data['games']['BEDWARS']['players']),
'arcade': int(data['games']['ARCADE']['players']),
'classic games': int(data['games']['LEGACY']['players']),
'battleground': int(data['games']['BATTLEGROUND']['players']),
'tntgames': int(data['games']['TNTGAMES']['players']),
'skywars': int(data['games']['SKYWARS']['players']),
'speedUHC': int(data['games']['SPEED_UHC']['players']),
'walls': int(data['games']['WALLS3']['players']),
'MCGO': int(data['games']['MCGO']['players']),
'housing': int(data['games']['HOUSING']['players']),
'UHC': int(data['games']['UHC']['players']),
'survival games': int(data['games']['SURVIVAL_GAMES']['players']),
'super smash': int(data['games']['SUPER_SMASH']['players']),
'skyblock': int(data['games']['SKYBLOCK']['players']),
'pit': int(data['games']['PIT']['players']),
'duels': int(data['games']['DUELS']['players']),
'build battle': int(data['games']['BUILD_BATTLE']['players']),
'murder mystery': int(data['games']['MURDER_MYSTERY']['players']),
'towerwars': int(data['games']['PROTOTYPE']['players']),
'replay': int(data['games']['REPLAY']['players']),
'limbo': int(data['games']['LIMBO']['players']),
'idle': int(data['games']['IDLE']['players']),
'queue': int(data['games']['QUEUE']['players'])
})
else:
data = requests.get(f'https://api.hypixel.net/counts?key={key}')
return int(data['playerCount'])