mirror of
https://github.com/baiqwerdvd/StarRailUID.git
synced 2025-05-05 19:23:45 +08:00
修复国际服抽卡记录导入 (#58)
* 修复国际服抽卡记录导入
* 🚨 `pre-commit-ci`修复格式错误
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
3904324153
commit
36e1f3d65a
@ -1,5 +1,6 @@
|
|||||||
# flake8: noqa
|
# flake8: noqa
|
||||||
OLD_URL = "https://api-takumi.mihoyo.com"
|
OLD_URL = "https://api-takumi.mihoyo.com"
|
||||||
|
OS_OLD_URL = "https://api-os-takumi.mihoyo.com"
|
||||||
NEW_URL = 'https://api-takumi-record.mihoyo.com'
|
NEW_URL = 'https://api-takumi-record.mihoyo.com'
|
||||||
OS_URL = "https://sg-public-api.hoyolab.com"
|
OS_URL = "https://sg-public-api.hoyolab.com"
|
||||||
OS_INFO_URL = "https://bbs-api-os.hoyolab.com"
|
OS_INFO_URL = "https://bbs-api-os.hoyolab.com"
|
||||||
@ -41,6 +42,9 @@ CHALLENGE_INFO_URL = f'{NEW_URL}/game_record/app/hkrpg/api/challenge'
|
|||||||
CHALLENGE_INFO_URL_OS = f'{OS_INFO_URL}/game_record/hkrpg/api/challenge'
|
CHALLENGE_INFO_URL_OS = f'{OS_INFO_URL}/game_record/hkrpg/api/challenge'
|
||||||
|
|
||||||
STAR_RAIL_GACHA_LOG_URL = f'{OLD_URL}/common/gacha_record/api/getGachaLog'
|
STAR_RAIL_GACHA_LOG_URL = f'{OLD_URL}/common/gacha_record/api/getGachaLog'
|
||||||
|
STAR_RAIL_GACHA_LOG_URL_OS = (
|
||||||
|
f'{OS_OLD_URL}/common/gacha_record/api/getGachaLog'
|
||||||
|
)
|
||||||
|
|
||||||
GET_FP_URL = 'https://public-data-api.mihoyo.com/device-fp/api/getFp'
|
GET_FP_URL = 'https://public-data-api.mihoyo.com/device-fp/api/getFp'
|
||||||
GET_FP_URL_OS = 'https://sg-public-data-api.hoyoverse.com/device-fp/api/getFp'
|
GET_FP_URL_OS = 'https://sg-public-data-api.hoyoverse.com/device-fp/api/getFp'
|
||||||
|
@ -16,7 +16,7 @@ gacha_type_meta_data = {
|
|||||||
|
|
||||||
|
|
||||||
async def get_new_gachalog_by_link(
|
async def get_new_gachalog_by_link(
|
||||||
gacha_url: str, full_data: Dict, is_force: bool
|
uid: str, gacha_url: str, full_data: Dict, is_force: bool
|
||||||
):
|
):
|
||||||
temp = []
|
temp = []
|
||||||
for gacha_name in gacha_type_meta_data:
|
for gacha_name in gacha_type_meta_data:
|
||||||
@ -29,7 +29,7 @@ async def get_new_gachalog_by_link(
|
|||||||
return {}
|
return {}
|
||||||
authkey = url_parse['authkey'][0]
|
authkey = url_parse['authkey'][0]
|
||||||
data = await mys_api.get_gacha_log_by_link_in_authkey(
|
data = await mys_api.get_gacha_log_by_link_in_authkey(
|
||||||
authkey, gacha_type, page, end_id
|
uid, authkey, gacha_type, page, end_id
|
||||||
)
|
)
|
||||||
await asyncio.sleep(0.45)
|
await asyncio.sleep(0.45)
|
||||||
if isinstance(data, int):
|
if isinstance(data, int):
|
||||||
@ -105,7 +105,7 @@ async def save_gachalogs(
|
|||||||
# 获取新抽卡记录
|
# 获取新抽卡记录
|
||||||
if raw_data is None:
|
if raw_data is None:
|
||||||
raw_data = await get_new_gachalog_by_link(
|
raw_data = await get_new_gachalog_by_link(
|
||||||
gacha_url, gachalogs_history, is_force
|
uid, gacha_url, gachalogs_history, is_force
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
new_data = {'始发跃迁': [], '群星跃迁': [], '角色跃迁': [], '光锥跃迁': []}
|
new_data = {'始发跃迁': [], '群星跃迁': [], '角色跃迁': [], '光锥跃迁': []}
|
||||||
|
@ -195,16 +195,19 @@ async def _draw_card_2(
|
|||||||
|
|
||||||
|
|
||||||
async def draw_role_card(sr_uid: str) -> Union[bytes, str]:
|
async def draw_role_card(sr_uid: str) -> Union[bytes, str]:
|
||||||
role_basic_info = await mys_api.get_role_basic_info(sr_uid)
|
|
||||||
role_index = await mys_api.get_role_index(sr_uid)
|
role_index = await mys_api.get_role_index(sr_uid)
|
||||||
|
# deal with hoyolab with no nickname and level api
|
||||||
if isinstance(role_index, int):
|
if int(str(sr_uid)[0]) < 6:
|
||||||
return get_error(role_index)
|
role_basic_info = await mys_api.get_role_basic_info(sr_uid)
|
||||||
if isinstance(role_basic_info, int):
|
if isinstance(role_basic_info, int):
|
||||||
|
return get_error(role_basic_info)
|
||||||
|
else:
|
||||||
role_basic_info = {}
|
role_basic_info = {}
|
||||||
role_basic_info['nickname'] = "开拓者"
|
role_basic_info['nickname'] = "开拓者"
|
||||||
role_basic_info['level'] = 0
|
role_basic_info['level'] = 0
|
||||||
# return get_error(role_basic_info)
|
|
||||||
|
if isinstance(role_index, int):
|
||||||
|
return get_error(role_index)
|
||||||
|
|
||||||
stats = role_index['stats']
|
stats = role_index['stats']
|
||||||
avatars = role_index['avatar_list']
|
avatars = role_index['avatar_list']
|
||||||
|
@ -108,6 +108,7 @@ class MysApi(_MysApi):
|
|||||||
|
|
||||||
async def get_gacha_log_by_link_in_authkey(
|
async def get_gacha_log_by_link_in_authkey(
|
||||||
self,
|
self,
|
||||||
|
uid: str,
|
||||||
authkey: str,
|
authkey: str,
|
||||||
gacha_type: str = '11',
|
gacha_type: str = '11',
|
||||||
page: int = 1,
|
page: int = 1,
|
||||||
@ -115,11 +116,22 @@ class MysApi(_MysApi):
|
|||||||
) -> Union[int, GachaLog]:
|
) -> Union[int, GachaLog]:
|
||||||
# server_id = 'cn_qd01' if
|
# server_id = 'cn_qd01' if
|
||||||
# uid[0] == '5' else 'cn_gf01'
|
# uid[0] == '5' else 'cn_gf01'
|
||||||
server_id = 'prod_gf_cn'
|
server_id = RECOGNIZE_SERVER.get(str(uid)[0])
|
||||||
|
if self.check_os(uid):
|
||||||
|
HEADER = copy.deepcopy(self._HEADER_OS)
|
||||||
|
HEADER['Cookie'] = await self.get_ck(uid, 'OWNER')
|
||||||
|
HEADER['DS'] = generate_os_ds()
|
||||||
|
header = HEADER
|
||||||
|
url = self.MAPI['STAR_RAIL_GACHA_LOG_URL_OS']
|
||||||
|
game_biz = 'hkrpg_global'
|
||||||
|
else:
|
||||||
|
header = self._HEADER
|
||||||
|
url = self.MAPI['STAR_RAIL_GACHA_LOG_URL']
|
||||||
|
game_biz = 'hkrpg_cn'
|
||||||
data = await self._mys_request(
|
data = await self._mys_request(
|
||||||
url=self.MAPI['STAR_RAIL_GACHA_LOG_URL'],
|
url=url,
|
||||||
method='GET',
|
method='GET',
|
||||||
header=self._HEADER,
|
header=header,
|
||||||
params={
|
params={
|
||||||
'authkey_ver': '1',
|
'authkey_ver': '1',
|
||||||
'sign_type': '2',
|
'sign_type': '2',
|
||||||
@ -131,7 +143,7 @@ class MysApi(_MysApi):
|
|||||||
'plat_type': 'pc',
|
'plat_type': 'pc',
|
||||||
'region': server_id,
|
'region': server_id,
|
||||||
'authkey': authkey,
|
'authkey': authkey,
|
||||||
'game_biz': 'hkrpg_cn',
|
'game_biz': game_biz,
|
||||||
'gacha_type': gacha_type,
|
'gacha_type': gacha_type,
|
||||||
'page': page,
|
'page': page,
|
||||||
'size': '20',
|
'size': '20',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user