1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-30 15:04:18 +00:00

Aggiunto controllo degli errori

This commit is contained in:
Steffo 2016-01-26 19:00:35 +01:00
parent f29e6e7b40
commit 7c5b50359d

15
osu.py
View file

@ -14,7 +14,10 @@ def getbeatmap(num):
'b': num, 'b': num,
} }
r = requests.get("https://osu.ppy.sh/api/get_beatmaps", params=parametri).json() r = requests.get("https://osu.ppy.sh/api/get_beatmaps", params=parametri).json()
return r[0] if len(r) >= 1:
return r[0]
else:
raise NameError
def getuser(user, mode=0): def getuser(user, mode=0):
@ -28,7 +31,10 @@ def getuser(user, mode=0):
'm': mode 'm': mode
} }
r = requests.get("https://osu.ppy.sh/api/get_user", params=parametri).json() r = requests.get("https://osu.ppy.sh/api/get_user", params=parametri).json()
return r[0] if len(r) >= 1:
return r[0]
else:
raise NameError
def getscores(beatmap, mode=0, limit=100, user=None): def getscores(beatmap, mode=0, limit=100, user=None):
@ -75,4 +81,7 @@ def getuserrecent(user, mode=0):
'limit': 1, 'limit': 1,
} }
r = requests.get("https://osu.ppy.sh/api/get_user_recent", params=parametri).json() r = requests.get("https://osu.ppy.sh/api/get_user_recent", params=parametri).json()
return r[0] if len(r) >= 1:
return r[0]
else:
raise NameError