From 2cbefbc1931de2bf9db8dfcf55e06198856af7c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B0=B4=E5=B1=85=E5=AE=A4?= Date: Mon, 14 Nov 2022 15:47:44 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20incorrect=20data=20return?= =?UTF-8?q?=20from=20DS=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/apihelper/helpers.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/apihelper/helpers.py b/modules/apihelper/helpers.py index 0c084d06..0d5a00cd 100644 --- a/modules/apihelper/helpers.py +++ b/modules/apihelper/helpers.py @@ -4,8 +4,7 @@ import random import string import time import uuid -from typing import Mapping -from urllib.parse import urlencode +from typing import Mapping, Any, Optional RECOGNIZE_SERVER = { "1": "cn_gf01", @@ -28,7 +27,7 @@ def hex_digest(text): return _md5.hexdigest() -def get_ds(ds_type: str = None, new_ds: bool = False, data: Mapping[str, str] = None, params: Mapping[str, str] = None): +def get_ds(ds_type: str = None, new_ds: bool = False, data: Any = None, params: Optional[Mapping[str, Any]] = None): """DS 算法 代码来自 https://github.com/y1ndan/genshinhelper :param ds_type: 1:ios 2:android 4:pc web 5:mobile web @@ -42,7 +41,7 @@ def get_ds(ds_type: str = None, new_ds: bool = False, data: Mapping[str, str] = t = str(int(time.time())) r = str(random.randint(100001, 200000)) # nosec b = json.dumps(data) if data else '' - q = urlencode(params) if params else '' + q = "&".join(f"{k}={v}" for k, v in sorted(params.items())) if params else '' c = hex_digest(f'salt={salt}&t={t}&r={r}&b={b}&q={q}') return f'{t},{r},{c}'