Coder Social home page Coder Social logo

littlenyima / honkai-starrail-toolkit Goto Github PK

View Code? Open in Web Editor NEW
121.0 3.0 4.0 402 KB

《崩坏:星穹铁道》工具箱,支持抽卡分析、帧率解锁等功能

Home Page: https://pypi.org/project/starrail-toolkit/

License: GNU General Public License v3.0

Python 99.77% Makefile 0.23%

honkai-starrail-toolkit's Introduction

《崩坏:星穹铁道》工具箱

logo

开发状态

主分支版本 开发分支版本 PyPI 版本 发行版版本
0.7.6 0.7.6 0.7.6 0.7.6

目前大部分计划中的 feature 已实现完成,历史开发计划见该页面

  • 获取官方公告
  • 支持 UP 池计算
  • 开拓月历
  • 米游社信息相关

常见问题解答

关于程序使用过程中存在的问题,可以参考本链接获得解答。若问题无法解决,欢迎提出反馈

安装方式

下载可执行程序

目前提供两种分发途径:GitHub Release蓝奏云,两种途径的内容相同,可以自行选择下载方式。

gui preview gacha

announcements

gui preview unlock

命令行安装

Python 用户可以直接使用 pip 安装本工具:

python3 -m pip install starrail-toolkit --force-reinstall --upgrade -i https://pypi.tuna.tsinghua.edu.cn/simple

从源码安装

若需要使用尚未推送到 PyPI 版本的功能,可通过源码安装:

git clone [email protected]:LittleNyima/honkai-starrail-toolkit.git
cd honkai-starrail-toolkit
python3 setup.py install

注:如果出现关于 qfluentwidgets 相关的报错,可能是因为默认 pypi 源的版本较低,可以使用以下命令安装最新版本的依赖:

pip install -U PySide6-Fluent-Widgets -i https://pypi.org/simple/

命令行使用指南

获取抽卡查询 API URL

请参考这个教程获取查询链接。

由此可以获得一个形如 https://api-takumi.mihoyo.com/common/gacha_record/api/getGachaLog?xxxxx 的 URL,后续步骤使用的就是这个 URL。注意:API URL 会在一定时间(大约 24 小时)后过期,过期后需要重新获取。

注:若为 Windows 平台,可以使用本工具自动检测 API URL。 首先登陆游戏,进入抽卡查询页面,当显示出一页抽卡查询结果后,退出游戏(由于 Windows 系统文件占用问题,若不退出,可能导致缓存无法读取),运行本工具,即可检测到抽卡查询 URL。如果需要切换账号,建议使用上述教程中的方法获取每个账号的 API URL,以便精确控制导出的账号。

导出抽卡记录

命令行导出

可以使用如下命令导出:

# 非 Windows 平台
hksr gacha --api https://api-takumi.mihoyo.com/xxx
# Windows 平台无需 --api 参数
hksr gacha

参数说明:

  • --api:(Windows 平台可选)API URL 地址。若为 Windows 平台,可以不填这个参数,而使用自动检测功能。
  • --export:(可选)导出格式选项。默认为导出全部格式,若仅需导出部分格式,可以替换对应参数。目前支持的格式有 csvhtmljsonmdsrgfuigfxlsx。例如,若只需要 json 与 xlsx 格式数据,可以替换为 --export json xlsx;如需导出全部格式,可以指定 --export all
  • --locale:(可选)控制输出语言。默认为输出简体中文,可选值为 en(英语)、chs(简体中文)。
  • --log-level:(可选)日志等级。控制日志的输出等级,默认为 DEBUG。若感觉输出的日志过多影响观感,建议将日志等级更改为 INFO,例如:--log-level INFO。(注意:若设置的日志等级过高,可能导致基本的信息无法显示,例如导出进度、导出位置、命令行版抽卡报告等)从高到低的可选值为 CRITICALERRORWARNINGINFODEBUG
  • --request-interval:(可选)请求间隔。两次请求之间的最小间隔,默认为 0.1。若某些情况下因请求过于频繁导致 IP 被 ban,可以适度把这个值调大一点。

如果想要进一步了解命令行使用方法,请参考命令行使用指南

导出结果示例

  • Excel 结果示例(为保护隐私已隐藏部分信息)

    xlsx
  • Markdown 结果示例:

    markdown

安全提醒

本仓库代码完全开源,且用户数据全部保存在本地,本项目不会上传任何用户数据。本项目仅在该 GitHub 仓库及 PyPI 进行分发,请仔细甄别下载到的程序,防止遭遇恶意程序。关于账号安全的更多信息,可以访问**本链接**了解。

Credits

本仓库用户界面部分基于 zhiyiYo/PyQt-Fluent-Widgets 实现,缓存解析部分参考了 sunfkny/genshin-gacha-export,用户界面设计参考了 BoxCatTeam/SRCat

honkai-starrail-toolkit's People

Contributors

littlenyima avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

honkai-starrail-toolkit's Issues

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

已经开启过游戏 刷新过 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

api导入

怎么把api导入到抽卡分析工具里面?我在工具界面好像没有看到导入api的入口,教程里面也没有看到方法。可以在教程里面添加一下使用方法吗?

bug反馈?

93240914b6ea5ad8916a3cde91d09c6
第一次用git传issues 不知道图片大佬能不能看到..
我的操作步骤:1:开抽卡分析程序
2:开游戏后打开抽卡页面 打开抽卡记录信息
3:关游戏 同步数据 报错:Traceback (most recent call last):
File "starrail qui common thread.py", line 18in runFile "starrail\quilinterfaces gacha sync.py", line 79, in workValueError: 提取 APIURL失败,遇到的问题: Payload is None, response: null

关于autodet.py的一点修改意见

get_cache_path函数,米哈游偷偷改了cache文件的存储路径规则,改为按照版本号生成,建议改成

def get_cache_path(game_install_path):
    from functools import cmp_to_key
    def cmp(ver_a: str, ver_b: str):
        ver_a = ver_a.split('.')
        ver_b = ver_b.split('.')
        ver_a = [int(a) for a in ver_a]
        ver_b = [int(b) for b in ver_b]
        length = min(len(ver_a), len(ver_b))
        for i in range(length):
            if ver_a[i] != ver_b[i]:
                return ver_b[i] - ver_a[i]
        return len(ver_b) - len(ver_a)
    logger.info('Getting gacha query cache path')
    cache_path = os.path.join(
        game_install_path,
        'StarRail_Data', 'webCaches'
    )
    maybe_dirs = os.listdir(cache_path)
    # 排序,要版本号大的在前
    maybe_dirs = sorted(maybe_dirs, key=cmp_to_key(cmp))
    cache_path = os.path.join(
        cache_path,
        maybe_dirs[0],
        'Cache',
        'Cache_Data',
        'data_2'
    )

    if not os.path.exists(cache_path):
        error_msg = (
            f'Cache path {cache_path} is not existing. Please visit '
            'the gacha querying page before exporting gacha data.'
        )
        logger.error(error_msg)
    return cache_path

关于windows上无法打开被占用文件的问题,建议改成robocopy来复制,get_api_from_cache建议改成

def get_api_from_cache(cache_path):
    def get_api_form_cache_windows(cache_path):
        tmpdir_path='{}\\tmp'.format(os.path.abspath('.'))
        try:
            if os.path.exists(tmpdir_path) and os.path.isfile(tmpdir_path):
                tmpdir_path='{}{:0>4d}'.format(tmpdir_path, int(time.time()) % 10000)
                os.mkdir(tmpdir_path)
            if not os.path.exists(tmpdir_path):
                os.mkdir(tmpdir_path)
        except BaseException as E:
            logger.error('TODO20240413:{}'.format(E))
        else:
            cmd = 'robocopy "{}" "{}" data_2'.format(os.path.dirname(cache_path), tmpdir_path)
            res = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            res.wait(5)
            assert 0==res.returncode, res.stderr.read()
            cache_path='{}\\data_2'.format(tmpdir_path)
            logger.info('Creating tmp file ok')
            return cache_path

    logger.info('Getting api URL from cache')

    import os, time, subprocess
    if os.name.startswith('nt'):
        cache_path = get_api_form_cache_windows(cache_path)
    with open(cache_path, 'rb') as f_cache:
        cache = f_cache.read()
    parts = cache.split(b'1/0/')
    parts = [part.split(b'\x00')[0].decode(errors='ignore') for part in parts]
    parts = map(get_url_from_text, parts)
    parts = list(filter(bool, parts))
    if not parts:
        error_msg = (
            'API URL is not found in cache. Please visit the gacha querying '
            'page before exporting gacha data.'
        )
        logger.error(error_msg)
        return ''
    return get_latest_url(parts)

在python3.9,崩铁2.22,windows10上测试了以上修改是ok的,希望版本能够更新一下,谢谢,懒得提merge请求了

导出的抽卡记录只有前五条

抽卡记录是通过参数end_idsize来检索,而不是通过page,你的请求只改动page是没用的。你用postman测一下大概就明白我说的什么意思了。

首次同步数据报错

操作步骤:开启游戏查询记录,然后关闭游戏,点击工具箱同步数据

版本为0.5.4

image

BUG反馈

image
疑似url又挂了
可恶 托帕歪姬子了

关于autodet.py的一点修改意见

get_cache_path函数,米哈游偷偷改了cache文件的存储路径规则,改为按照版本号生成,建议改成

def get_cache_path(game_install_path):
    from functools import cmp_to_key
    def cmp(ver_a: str, ver_b: str):
        ver_a = ver_a.split('.')
        ver_b = ver_b.split('.')
        ver_a = [int(a) for a in ver_a]
        ver_b = [int(b) for b in ver_b]
        length = min(len(ver_a), len(ver_b))
        for i in range(length):
            if ver_a[i] != ver_b[i]:
                return ver_b[i] - ver_a[i]
        return len(ver_b) - len(ver_a)
    logger.info('Getting gacha query cache path')
    cache_path = os.path.join(
        game_install_path,
        'StarRail_Data', 'webCaches'
    )
    maybe_dirs = os.listdir(cache_path)
    # 排序,要版本号大的在前
    maybe_dirs = sorted(maybe_dirs, key=cmp_to_key(cmp))
    cache_path = os.path.join(
        cache_path,
        maybe_dirs[0],
        'Cache',
        'Cache_Data',
        'data_2'
    )

    if not os.path.exists(cache_path):
        error_msg = (
            f'Cache path {cache_path} is not existing. Please visit '
            'the gacha querying page before exporting gacha data.'
        )
        logger.error(error_msg)
    return cache_path

关于windows上无法打开被占用文件的问题,建议改成robocopy来复制,get_api_from_cache建议改成

def get_api_from_cache(cache_path):
    def get_api_form_cache_windows(cache_path):
        tmpdir_path='{}\\tmp'.format(os.path.abspath('.'))
        try:
            if os.path.exists(tmpdir_path) and os.path.isfile(tmpdir_path):
                tmpdir_path='{}{:0>4d}'.format(tmpdir_path, int(time.time()) % 10000)
                os.mkdir(tmpdir_path)
            if not os.path.exists(tmpdir_path):
                os.mkdir(tmpdir_path)
        except BaseException as E:
            logger.error('TODO20240413:{}'.format(E))
        else:
            cmd = 'robocopy "{}" "{}" data_2'.format(os.path.dirname(cache_path), tmpdir_path)
            res = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            res.wait(5)
            assert 0==res.returncode, res.stderr.read()
            cache_path='{}\\data_2'.format(tmpdir_path)
            logger.info('Creating tmp file ok')
            return cache_path

    logger.info('Getting api URL from cache')

    import os, time, subprocess
    if os.name.startswith('nt'):
        cache_path = get_api_form_cache_windows(cache_path)
    with open(cache_path, 'rb') as f_cache:
        cache = f_cache.read()
    parts = cache.split(b'1/0/')
    parts = [part.split(b'\x00')[0].decode(errors='ignore') for part in parts]
    parts = map(get_url_from_text, parts)
    parts = list(filter(bool, parts))
    if not parts:
        error_msg = (
            'API URL is not found in cache. Please visit the gacha querying '
            'page before exporting gacha data.'
        )
        logger.error(error_msg)
        return ''
    return get_latest_url(parts)

在python3.9,崩铁2.22,windows10上测试了以上修改是ok的,希望版本能够更新一下,谢谢,懒得提merge请求了

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.