From 503275a020214ab9f8fe2ff5974d1830d04f0db0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=98KimigaiiWuyi=E2=80=99?= <444835641@qq.com> Date: Wed, 24 Apr 2024 10:46:21 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=BD=20=E4=BF=AE=E5=A4=8D`mys.request.g?= =?UTF-8?q?et=5Fgacha=5Flog=5Fby=5Fauthkey()`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gsuid_core/utils/api/mys/api.py | 4 +++- gsuid_core/utils/api/mys/request.py | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/gsuid_core/utils/api/mys/api.py b/gsuid_core/utils/api/mys/api.py index 5b0bfb5..5ba3402 100644 --- a/gsuid_core/utils/api/mys/api.py +++ b/gsuid_core/utils/api/mys/api.py @@ -52,7 +52,9 @@ # 通过Stoken获取AuthKey GET_AUTHKEY_URL = f'{OLD_URL}/binding/api/genAuthKey' # 通过AuthKey获取gachalogs -GET_GACHA_LOG_URL = f'{HK4_URL}/event/gacha_info/api/getGachaLog' +GET_GACHA_LOG_URL = ( + 'https://public-operation-hk4e.mihoyo.com/gacha_info/api/getGachaLog' +) GET_GACHA_LOG_URL_OS = f'{HK4_URL_OS}/event/gacha_info/api/getGachaLog' # 通过GameToken获取Stoken GET_STOKEN = f'{PASSPORT_URL}/account/ma-cn-session/app/getTokenByGameToken' diff --git a/gsuid_core/utils/api/mys/request.py b/gsuid_core/utils/api/mys/request.py index 376ab97..02f6ef2 100644 --- a/gsuid_core/utils/api/mys/request.py +++ b/gsuid_core/utils/api/mys/request.py @@ -5,6 +5,7 @@ from __future__ import annotations import copy +import json import time import uuid import random @@ -423,7 +424,7 @@ async def _mys_request( ) try: raw_data = resp.json() - except ContentTypeError: + except (ContentTypeError, json.decoder.JSONDecodeError): _raw_data = resp.text raw_data = {'retcode': -999, 'data': _raw_data} @@ -1006,15 +1007,16 @@ async def get_gacha_log_by_authkey( if isinstance(authkey_rawdata, int): return authkey_rawdata authkey = authkey_rawdata['authkey'] + url = self.MAPI['GET_GACHA_LOG_URL'] data = await self._mys_request( - url=self.MAPI['GET_GACHA_LOG_URL'], + url=url, method='GET', header=self._HEADER, params={ 'authkey_ver': '1', 'sign_type': '2', 'auth_appid': 'webview_gacha', - 'init_type': '200', + 'init_type': gacha_type, 'gacha_id': 'fecafa7b6560db5f3182222395d88aaa6aaac1bc', 'timestamp': str(int(time.time())), 'lang': 'zh-cn',