mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
23 lines
651 B
Python
23 lines
651 B
Python
|
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")
|