diff --git a/StarRailUID/sruid_utils/api/mys/api.py b/StarRailUID/sruid_utils/api/mys/api.py index 38d7380..bcc7a22 100644 --- a/StarRailUID/sruid_utils/api/mys/api.py +++ b/StarRailUID/sruid_utils/api/mys/api.py @@ -24,6 +24,8 @@ STAR_RAIL_AVATAR_INFO_URL = ( f'{NEW_URL}/game_record/app/hkrpg/api/avatar/info' # 角色详细信息接口 ) +STAR_RAIL_GACHA_LOG_URL = f'{OLD_URL}/common/gacha_record/api/getGachaLog' + # CREATE_QRCODE = f'{OLD_URL}/event/bbs_sign_reward/gen_auth_code' diff --git a/StarRailUID/sruid_utils/api/mys/models.py b/StarRailUID/sruid_utils/api/mys/models.py index c01bacb..ff5e763 100644 --- a/StarRailUID/sruid_utils/api/mys/models.py +++ b/StarRailUID/sruid_utils/api/mys/models.py @@ -1,5 +1,31 @@ from typing import Any, Dict, List, Optional, TypedDict +################ +# 抽卡记录相关 # +################ + + +class SingleGachaLog(TypedDict): + uid: str + gacha_id: str + gacha_type: str + item_id: str + count: str + time: str + name: str + lang: str + item_type: str + rank_type: str + id: str + + +class GachaLog(TypedDict): + page: str + size: str + list: List[SingleGachaLog] + region: str + region_time_zone: int + class RoleBasicInfo(TypedDict): avatar: str diff --git a/StarRailUID/utils/mys_api.py b/StarRailUID/utils/mys_api.py index 0186ed5..56ba729 100644 --- a/StarRailUID/utils/mys_api.py +++ b/StarRailUID/utils/mys_api.py @@ -1,4 +1,5 @@ import copy +import time import random from typing import Dict, Union, cast from string import digits, ascii_letters @@ -14,6 +15,7 @@ from gsuid_core.utils.api.mys.tools import ( from .api import srdbsqla from ..sruid_utils.api.mys.api import _API from ..sruid_utils.api.mys.models import ( + GachaLog, RoleIndex, AvatarInfo, MonthlyAward, @@ -68,6 +70,42 @@ class MysApi(_MysApi): data = cast(RoleIndex, data['data']) return data + async def get_gacha_log_by_link_in_authkey( + self, + authkey: str, + gacha_type: str = '11', + page: int = 1, + end_id: str = '0', + ) -> Union[int, GachaLog]: + # server_id = 'cn_qd01' if + # uid[0] == '5' else 'cn_gf01' + server_id = 'prod_gf_cn' + data = await self._mys_request( + url=self.MAPI['STAR_RAIL_GACHA_LOG_URL'], + method='GET', + header=self._HEADER, + params={ + 'authkey_ver': '1', + 'sign_type': '2', + 'auth_appid': 'webview_gacha', + 'default_gacha_type': 11, + 'gacha_id': 'dbebc8d9fbb0d4ffa067423482ce505bc5ea', + 'timestamp': str(int(time.time())), + 'lang': 'zh-cn', + 'plat_type': 'pc', + 'region': server_id, + 'authkey': authkey, + 'game_biz': 'hkrpg_cn', + 'gacha_type': gacha_type, + 'page': page, + 'size': '5', + 'end_id': end_id, + }, + ) + if isinstance(data, Dict): + data = cast(GachaLog, data['data']) + return data + async def get_avatar_info( self, uid: str, avatar_id: int, need_wiki: bool = False ) -> Union[AvatarInfo, int]: