27 lines
1.1 KiB
Python
27 lines
1.1 KiB
Python
import aiohttp
|
|
from worthless import constants
|
|
|
|
|
|
class Launcher:
|
|
def __init__(self):
|
|
self._api = constants.LAUNCHER_API_URL
|
|
|
|
# Workaround because miHoYo uses retcode for their API
|
|
@staticmethod
|
|
async def _get(url, **kwargs):
|
|
async with aiohttp.ClientSession() as session:
|
|
rsp = await session.get(url, **kwargs)
|
|
rsp_json = await rsp.json()
|
|
# Why retcode seriously? They can just make the page not returning 200 status code.
|
|
if rsp_json["retcode"] != 0:
|
|
raise aiohttp.ClientResponseError(code=rsp_json["retcode"],
|
|
message=rsp_json["message"],
|
|
history=rsp.history,
|
|
request_info=rsp.request_info)
|
|
return rsp_json
|
|
|
|
async def get_version_info(self):
|
|
rsp = await self._get(self._api + "/resource", params={"key": "gcStgarh",
|
|
"launcher_id": "10"})
|
|
return rsp
|