mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-27 13:34:28 +00:00
Some bugfixes
This commit is contained in:
parent
6e7d702c00
commit
e1dafb9528
1 changed files with 6 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
|
loop = asyncio.get_event_loop()
|
||||||
|
|
||||||
# Get player database from the db.json file
|
# Get player database from the db.json file
|
||||||
file = open("db.json")
|
file = open("db.json")
|
||||||
|
@ -16,12 +17,14 @@ for player in db:
|
||||||
# Get player data
|
# Get player data
|
||||||
async def get_player_data(platform: str, region: str, battletag: str):
|
async def get_player_data(platform: str, region: str, battletag: str):
|
||||||
# Unofficial API requires - for discriminator numbers
|
# Unofficial API requires - for discriminator numbers
|
||||||
battletag.replace("#", "-")
|
battletag = battletag.replace("#", "-")
|
||||||
# GET the json unofficial API response
|
# GET the json unofficial API response
|
||||||
loop = asyncio.get_event_loop()
|
r = await loop.run_in_executor(None, requests.get,
|
||||||
r = await loop.run_in_executor(None, requests.get, 'https://api.lootbox.eu/{platform}/{region}/{battletag}/profile')
|
'https://api.lootbox.eu/{platform}/{region}/{battletag}/profile'.format(**locals()))
|
||||||
# Ensure the request is successful
|
# Ensure the request is successful
|
||||||
if r.status_code == 200:
|
if r.status_code == 200:
|
||||||
return r.json()
|
return r.json()
|
||||||
elif r.status_code == 404:
|
elif r.status_code == 404:
|
||||||
raise Exception("Player not found.")
|
raise Exception("Player not found.")
|
||||||
|
|
||||||
|
loop.run_until_complete(get_player_data("pc", "eu", "SteffoRYG#2876"))
|
||||||
|
|
Loading…
Reference in a new issue