GenshinUID icon indicating copy to clipboard operation
GenshinUID copied to clipboard

能不能加个抽卡记录分析

Open SonderXiaoming opened this issue 2 years ago • 11 comments

我看github上似乎有是通过URL来获取抽卡数据,而且还能做出饼图分析之类的,能不能整合进去? 我想看看群友是非是欧

SonderXiaoming avatar Mar 19 '22 17:03 SonderXiaoming

因为获取URL的方式不太容易并且基本是一次性的,而且现在有很多成熟的本地工具可以分析,然后截图到群里也是一样的效果;所以暂时不会添加这个功能

KimigaiiWuyi avatar Mar 20 '22 05:03 KimigaiiWuyi

主要是不方便吧,我用机器人更方便一点,而且工具使用对部分人来说比较复杂

SonderXiaoming avatar Mar 20 '22 05:03 SonderXiaoming

抽卡分析依赖本地的原神日志或者程序

无法在云端实现,也就无法实现抽卡导出

MingxuanGame avatar Mar 20 '22 05:03 MingxuanGame

抽卡分析依赖本地的原神日志或者程序

无法在云端实现,也就无法实现抽卡导出

不是通过url的吗,一次性的url,读取应该可以把,主要感觉url失效的太快,获取挺麻烦的,不太实用

KimigaiiWuyi avatar Mar 20 '22 05:03 KimigaiiWuyi

github已有类似插件 https://github.com/monsterxcn/nonebot-plugin-gachalogs

lgc2333 avatar Mar 20 '22 14:03 lgc2333

github已有类似插件 https://github.com/monsterxcn/nonebot-plugin-gachalogs

这个是获取一次url就行了吗?还是每次查询都要获取新的url?太久没用过类似软件,不知道url持续性如何

KimigaiiWuyi avatar Mar 21 '22 04:03 KimigaiiWuyi

github已有类似插件 https://github.com/monsterxcn/nonebot-plugin-gachalogs

这个是获取一次url就行了吗?还是每次查询都要获取新的url?太久没用过类似软件,不知道url持续性如何

nb2插件,我只会星乃嘤嘤嘤,大佬你可以试一下

SonderXiaoming avatar Mar 21 '22 16:03 SonderXiaoming

github已有类似插件 https://github.com/monsterxcn/nonebot-plugin-gachalogs

这个是获取一次url就行了吗?还是每次查询都要获取新的url?太久没用过类似软件,不知道url持续性如何

首次使用需要发送一次链接,之后如果authkey失效使用命令会输出缓存记录,否则通过先前的authkey更新一次记录,也可以使用命令强制更新 5df04b67d2051b2a

lgc2333 avatar Mar 25 '22 11:03 lgc2333

github已有类似插件 https://github.com/monsterxcn/nonebot-plugin-gachalogs

这个是获取一次url就行了吗?还是每次查询都要获取新的url?太久没用过类似软件,不知道url持续性如何

主要是需要一个含有专用 authkey 的链接(抽卡记录历史页面链接)就行。authkey 有效期 24 小时。各种分析软件也就是从日志文件里读了这个链接或者要求用户输入这个链接。

monsterxcn avatar Aug 02 '22 15:08 monsterxcn

因为过期时间有些短,实际在扣扣上体验不是那么好,不过考虑大伙用小程序应该也是要输链接的吧?

monsterxcn avatar Aug 02 '22 15:08 monsterxcn

因为过期时间有些短,实际在扣扣上体验不是那么好,不过考虑大伙用小程序应该也是要输链接的吧?

差不多,我觉得比小程序方便一点?

SonderXiaoming avatar Aug 02 '22 15:08 SonderXiaoming

自动更新抽卡记录链接中的 AuthKey 并生成链接,我从我的屎山里精炼了一下(

请求的 Headers 我照抓包的请求原样写的,可能有些请求头不必要。

@KimigaiiWuyi 剩下的交给你了,溜溜..

import json
import random
import string
import uuid
from hashlib import md5
from time import time
from typing import Dict
from urllib import parse

from httpx import AsyncClient

CLIENT_SALT = "dWCcD2FsOUXEstC5f9xubswZxEeoBOTc"
CLIENT_VERSION = "2.28.1"
CLIENT_TYPE = "2"
AUTHKEY_API = "https://api-takumi.mihoyo.com/binding/api/genAuthKey"
ROOT_URL = "https://hk4e-api.mihoyo.com/event/gacha_info/api/getGachaLog"
ROOT_OVERSEA_URL = "https://hk4e-api-os.mihoyo.com/event/gacha_info/api/getGachaLog"


async def genAuthKey(cookie: str, data: Dict) -> str:
    t = str(int(time()))
    r = "".join(random.sample(string.ascii_lowercase + string.digits, 6))
    m = md5(f"salt={CLIENT_SALT}&t={t}&r={r}".encode()).hexdigest()
    headers = {
        "content-type": "application/json; charset=UTF-8",
        "cookie": cookie,
        "ds": f"{t},{r},{m}",
        "host": "api-takumi.mihoyo.com",
        "referer": "https://app.mihoyo.com",
        "user-agent": "okhttp/4.8.0",
        "x-rpc-app_version": CLIENT_VERSION,
        "x-rpc-channel": "mihoyo",
        "x-rpc-client_type": CLIENT_TYPE,
        "x-rpc-device_id": str(uuid.uuid3(uuid.NAMESPACE_URL, cookie)),
        "x-rpc-device_model": "SM-977N",
        "x-rpc-device_name": "Samsung SM-G977N",
        "x-rpc-sys_version": "12",
    }
    async with AsyncClient() as client:
        try:
            res = await client.post(
                AUTHKEY_API,
                headers=headers,
                content=json.dumps(data, ensure_ascii=False),
            )
            return res.json()["data"]["authkey"]
        except Exception as e:
            # logger.error(e)
            return ""


async def getLogsUrl() -> str:
    cookie = "stoken=xxx;stuid=xxx;mid=xxx"  # mid 不带似乎也没影响
    data = {
        "auth_appid": "webview_gacha",
        "game_biz": "{game_biz}",  # "hk4e_cn"
        "game_uid": "{game_uid}",  # "100000123"
        "region": "{region}",  # "cn_gf01"
    }
    authkey = await genAuthKey(cookie, data)
    querys = {
        "authkey_ver": "1",
        "sign_type": "2",
        "auth_appid": "webview_gacha",
        "init_type": "200",  # init 哪个池子都无所谓,但下面这个 gacha_id 跟这里对应
        "gacha_id": "fecafa7b6560db5f3182222395d88aaa6aaac1bc",
        "timestamp": str(int(time())),  # 实际好像并不是请求时的时间戳
        "lang": "zh-cn",
        "device_type": "mobile",
        # "ext": {"loc":{"x":-6XX.817XXX671875,"y":XX2.54130XXX199219,"z":-X7.45397XX921875},"platform":"IOS"},  # "platform":"Android"
        # "game_version": "CNRELiOS2.8.0_R9182063_S9401797_D9464149",  # "CNRELAndroid2.8.0_R9182063_S9401797_D9464149"
        "plat_type": "ios",  # "android"
        "region": "{region}",  # "cn_gf01"
        "authkey": authkey,
        "game_biz": "{game_biz}",  # "hk4e_cn"
        "gacha_type": "301",  # 查询时更新
        "page": "1",  # 查询时更新
        "size": "6",  # 查询时更新
        "end_id": 0,  # 查询时更新
    }
    url = ROOT_URL + "?" + parse.urlencode(querys)
    # logger.info(url)
    return url

monsterxcn avatar Aug 20 '22 06:08 monsterxcn

自动更新抽卡记录链接中的 AuthKey 并生成链接,我从我的屎山里精炼了一下(

请求的 Headers 我照抓包的请求原样写的,可能有些请求头不必要。

@KimigaiiWuyi 剩下的交给你了,溜溜..

import json
import random
import string
import uuid
from hashlib import md5
from time import time
from typing import Dict
from urllib import parse

from httpx import AsyncClient

CLIENT_SALT = "dWCcD2FsOUXEstC5f9xubswZxEeoBOTc"
CLIENT_VERSION = "2.28.1"
CLIENT_TYPE = "2"
AUTHKEY_API = "https://api-takumi.mihoyo.com/binding/api/genAuthKey"
ROOT_URL = "https://hk4e-api.mihoyo.com/event/gacha_info/api/getGachaLog"
ROOT_OVERSEA_URL = "https://hk4e-api-os.mihoyo.com/event/gacha_info/api/getGachaLog"


async def genAuthKey(cookie: str, data: Dict) -> str:
    t = str(int(time()))
    r = "".join(random.sample(string.ascii_lowercase + string.digits, 6))
    m = md5(f"salt={CLIENT_SALT}&t={t}&r={r}".encode()).hexdigest()
    headers = {
        "content-type": "application/json; charset=UTF-8",
        "cookie": cookie,
        "ds": f"{t},{r},{m}",
        "host": "api-takumi.mihoyo.com",
        "referer": "https://app.mihoyo.com",
        "user-agent": "okhttp/4.8.0",
        "x-rpc-app_version": CLIENT_VERSION,
        "x-rpc-channel": "mihoyo",
        "x-rpc-client_type": CLIENT_TYPE,
        "x-rpc-device_id": str(uuid.uuid3(uuid.NAMESPACE_URL, cookie)),
        "x-rpc-device_model": "SM-977N",
        "x-rpc-device_name": "Samsung SM-G977N",
        "x-rpc-sys_version": "12",
    }
    async with AsyncClient() as client:
        try:
            res = await client.post(
                AUTHKEY_API,
                headers=headers,
                content=json.dumps(data, ensure_ascii=False),
            )
            return res.json()["data"]["authkey"]
        except Exception as e:
            # logger.error(e)
            return ""


async def getLogsUrl() -> str:
    cookie = "stoken=xxx; stuid=xxx; mid=xxx"
    data = {
        "auth_appid": "webview_gacha",
        "game_biz": "{game_biz}",  # "hk4e_cn"
        "game_uid": "{game_uid}",  # "100000123"
        "region": "{region}",  # "cn_gf01"
    }
    authkey = await genAuthKey(cookie, data)
    querys = {
        "authkey_ver": "1",
        "sign_type": "2",
        "auth_appid": "webview_gacha",
        "init_type": "200",  # init 哪个池子都无所谓,但下面这个 gacha_id 跟这里对应
        "gacha_id": "fecafa7b6560db5f3182222395d88aaa6aaac1bc",
        "timestamp": str(int(time())),  # 实际好像并不是请求时的时间戳
        "lang": "zh-cn",
        "device_type": "mobile",
        # "ext": {"loc":{"x":-6XX.817XXX671875,"y":XX2.54130XXX199219,"z":-X7.45397XX921875},"platform":"IOS"},  # "platform":"Android"
        # "game_version": "CNRELiOS2.8.0_R9182063_S9401797_D9464149",  # "CNRELAndroid2.8.0_R9182063_S9401797_D9464149"
        "plat_type": "ios",  # "android"
        "region": "{region}",  # "cn_gf01"
        "authkey": authkey,
        "game_biz": "{game_biz}",  # "hk4e_cn"
        "gacha_type": "301",  # 查询时更新
        "page": "1",  # 查询时更新
        "size": "6",  # 查询时更新
        "end_id": 0,  # 查询时更新
    }
    url = ROOT_URL + "?" + parse.urlencode(querys)
    # logger.info(url)
    return url

ok,我摸鱼做一个

KimigaiiWuyi avatar Aug 20 '22 07:08 KimigaiiWuyi

https://github.com/KimigaiiWuyi/GenshinUID/commit/a6dfb9489c702dee11ce9afb92ce63132d2727c0

lgc2333 avatar Aug 27 '22 03:08 lgc2333

已增加

KimigaiiWuyi avatar Aug 30 '22 06:08 KimigaiiWuyi

github已有类似插件monebot-plugin-gachalogs本人正在使用2022年3月20日 01:14,SonderXiaoming @.***>写道:

我看github上似乎有是通过URL来获取抽卡数据,而且还能做出饼图分析之类的,能不能整合进去?

我想看看群友是非是欧

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>

lgc2333 avatar Oct 11 '22 07:10 lgc2333