mirror of
https://github.com/PaiGramTeam/PamGram.git
synced 2024-11-22 06:17:54 +00:00
🎨 Added methods to generate the device_id from the v2 cookies
This commit is contained in:
parent
40e3ab0cce
commit
ceff8d0340
@ -13,6 +13,14 @@ from utils.patch.methods import patch, patchable
|
|||||||
DEVICE_ID = get_device_id()
|
DEVICE_ID = get_device_id()
|
||||||
|
|
||||||
|
|
||||||
|
def get_account_mid_v2(cookies: typing.Dict[str, str]) -> typing.Optional[str]:
|
||||||
|
for name, value in cookies.items():
|
||||||
|
if name == "account_mid_v2":
|
||||||
|
return value
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
@patch(genshin.client.components.calculator.CalculatorClient) # noqa
|
@patch(genshin.client.components.calculator.CalculatorClient) # noqa
|
||||||
class CalculatorClient:
|
class CalculatorClient:
|
||||||
@patchable
|
@patchable
|
||||||
@ -81,11 +89,15 @@ class BaseClient:
|
|||||||
"ds": ds.generate_dynamic_secret(),
|
"ds": ds.generate_dynamic_secret(),
|
||||||
}
|
}
|
||||||
elif region == types.Region.CHINESE:
|
elif region == types.Region.CHINESE:
|
||||||
uid = self.cookie_manager.get_user_id()
|
account_id = self.cookie_manager.user_id
|
||||||
if uid:
|
if account_id:
|
||||||
device_id = hex_digest(str(uid))
|
device_id = hex_digest(str(account_id))
|
||||||
else:
|
else:
|
||||||
device_id = DEVICE_ID
|
account_mid_v2 = get_account_mid_v2(self.cookie_manager.cookies)
|
||||||
|
if account_mid_v2:
|
||||||
|
device_id = hex_digest(account_mid_v2)
|
||||||
|
else:
|
||||||
|
device_id = DEVICE_ID
|
||||||
_app_version, _client_type, _ds = get_ds(new_ds=True, data=data, params=params)
|
_app_version, _client_type, _ds = get_ds(new_ds=True, data=data, params=params)
|
||||||
ua = get_ua(device="Paimon Build " + device_id[0:5], version=_app_version)
|
ua = get_ua(device="Paimon Build " + device_id[0:5], version=_app_version)
|
||||||
headers = {
|
headers = {
|
||||||
@ -195,11 +207,15 @@ class DailyRewardClient:
|
|||||||
params["uid"] = player_id
|
params["uid"] = player_id
|
||||||
params["region"] = utility.recognize_genshin_server(player_id)
|
params["region"] = utility.recognize_genshin_server(player_id)
|
||||||
|
|
||||||
account_id = self.cookie_manager.get_user_id()
|
account_id = self.cookie_manager.user_id
|
||||||
if account_id:
|
if account_id:
|
||||||
device_id = hex_digest(str(account_id))
|
device_id = hex_digest(str(account_id))
|
||||||
else:
|
else:
|
||||||
device_id = DEVICE_ID
|
account_mid_v2 = get_account_mid_v2(self.cookie_manager.cookies)
|
||||||
|
if account_mid_v2:
|
||||||
|
device_id = hex_digest(account_mid_v2)
|
||||||
|
else:
|
||||||
|
device_id = DEVICE_ID
|
||||||
if endpoint == "sign":
|
if endpoint == "sign":
|
||||||
_app_version, _client_type, _ds = get_ds()
|
_app_version, _client_type, _ds = get_ds()
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user