1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00
royalnet/osu.py

23 lines
651 B
Python
Raw Normal View History

2017-02-07 21:24:49 +00:00
import asyncio
import requests
loop = asyncio.get_event_loop()
# Load Osu API key from the osutoken.txt file
file = open("osutoken.txt", "r")
token = file.read()
file.close()
async def get_user(user, mode=0):
print("[Osu!] Getting profile data for {} mode {}".format(user, mode))
params = {
"k": token,
"m": mode,
"u": user
}
# Get the data
r = await loop.run_in_executor(None, requests.get, 'https://osu.ppy.sh/api/get_user?k={k}&m={m}&u={u}'.format(**params))
if r.status_code == 200:
return r.json()[0]
else:
raise Exception("[Osu!] Unhandled exception during the API request")