LittleNyima / honkai-starrail-toolkit

《崩坏:星穹铁道》工具箱,支持抽卡分析、帧率解锁等功能
https://pypi.org/project/starrail-toolkit/
GNU General Public License v3.0
125 stars 4 forks source link

下载windows gui版本 运行报错 "提取 API URL 失败,请关闭游戏或重新查询抽卡信息后重试。" #3

Closed Ricardo-Riley closed 1 year ago

Ricardo-Riley commented 1 year ago

已经开启过游戏 刷新过 cache2 文件。 下载源码运行

2023-05-12 13:52:08,310 gacha\service.py Line 38 - [INFO] Length of payload.data.list: 0
2023-05-12 13:52:31,049 gacha\service.py Line 77 - [CRITICAL] Error while checking response from api URL, exitting
  File "D:\Person\project\per\honkai-starrail-toolkit-develop\honkai-starrail-toolkit-develop\starrail\gacha\service.py", line 78, in export_gacha_from_api
    raise ValueError('Invalid or expired api, please check your input')
ValueError: Invalid or expired api, please check your input

定位

    def syncGachaData(self):
        self.logAndUpdateState(babelfish.ui_extracting_api_url())
        api_url = service.detect_api_url()
        response, code = service.fetch_json(api_url)
        valid = service.check_response(response, code)

网页访问api_url返回

{
    "retcode": 0,
    "message": "OK",
    "data": {
        "page": "1",
        "size": "5",
        "list": [],
        "region": "prod_gf_cn",
        "region_time_zone": 8
    }
}

在 ‘ service.check_response’ 抛异常了

if not payload['data']['list']:
        logger.info(
            f'Length of payload.data.list: '
            f'{len(payload["data"]["list"])}',
        )
        return False

源码 版本 20230512 12:00 直接下载的develop.zip gui程序版本 StarRailToolkit-v0.5.4_windows-64bit

LittleNyima commented 1 year ago

看上去提取到的查询 URL 是没有问题的,话说是不是因为你查询的那个页面没有抽卡信息呀,比如某个类别的抽卡你一次都没有抽过,可能会导致这个情况。下个版本我再优化一下这块的逻辑

Ricardo-Riley commented 1 year ago

两个请求链接 第一个timestamp=1681910033,第二个timestamp=1681909990

getGachaLog?authkey_ver=1&sign_type=2&auth_appid=webview_gacha&win_mode=fullscreen&gacha_id=ceef3b655e094f3f603c57e581c98dad09b3&timestamp=1681910033&region=prod_gf_cn&default_gacha_type=12&lang=zh-cn&&plat_type=pc&page=1&size=5&gacha_type=12&end_id

getGachaLog?authkey_ver=1&sign_type=2&auth_appid=webview_gacha&win_mode=fullscreen&gacha_id=ad9815cdf2308104c377aac42c7f0cdd8d&timestamp=1681909990&region=prod_gf_cn&default_gacha_type=1&lang=zh-cn&plat_type=pc&page=3&size=5&gacha_type=1&end_id=1683868200000786324

按时间排序后 第一个链接一直被选中,访问,但是第一个链接返回内容是

{
    "retcode": 0,
    "message": "OK",
    "data": {
        "page": "1",
        "size": "5",
        "list": [],
        "region": "prod_gf_cn",
        "region_time_zone": 8
    }
}

一直返回空。 如果改成 end_id 排序 就正常 导出结果 image

LittleNyima commented 1 year ago

看来和我猜测的原因是一样的,我修改一下校验 API 有效性的逻辑

LittleNyima commented 1 year ago

已修复,你可以拉一下最新的代码,测试一下功能正常了没有

Ricardo-Riley commented 1 year ago

2023-05-15 09:42:15,638 gacha\fetch.py Line 27 - [DEBUG] { "retcode": 0, "message": "OK", "data": { "page": "1", "size": "5", "list": [], "region": "prod_gf_cn", "region_time_zone": 8 } } 2023-05-15 09:42:15,638 gacha\service.py Line 42 - [INFO] Length of payload.data.list: 0.It is valid, but reaches the end of gacha record list. Traceback (most recent call last): File "D:/Person/project/per/honkai-starrail-toolkit-develop/honkai-starrail-toolkit-develop/starrail/entry/cli.py", line 89, in cli_entry() File "D:/Person/project/per/honkai-starrail-toolkit-develop/honkai-starrail-toolkit-develop/starrail/entry/cli.py", line 83, in cli_entry request_interval=args.request_interval, File "D:\Person\project\per\honkai-starrail-toolkit-develop\honkai-starrail-toolkit-develop\starrail\gacha\service.py", line 85, in export_gacha_from_api uid = response['data']['list'][0]['uid'] IndexError: list index out of range Press Enter to exit.

LittleNyima commented 1 year ago

感谢反馈,已经定位到问题,我会尽快修复

LittleNyima commented 1 year ago

问题已修复,请更新程序后再试一下