mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-22 15:36:44 +00:00
🎨 Update get_ua
function for requests
This commit is contained in:
parent
3b9596c6af
commit
e96da60d0c
@ -83,9 +83,9 @@ def get_recognize_server(uid: int) -> str:
|
||||
raise TypeError(f"UID {uid} isn't associated with any recognize server")
|
||||
|
||||
|
||||
def get_headers(device: str = "Paimon Build", version: str = "2.36.1"):
|
||||
def get_ua(device: str = "Paimon Build", version: str = "2.36.1"):
|
||||
return (
|
||||
f"Mozilla/5.0 (Linux; Android 12; {device}; wv) "
|
||||
"AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/103.0.5060.129 Mobile Safari/537.36 "
|
||||
f"miHoYoBBS/{version}"
|
||||
)
|
||||
)
|
||||
|
@ -13,7 +13,7 @@ from httpx import AsyncClient
|
||||
from pydantic import BaseModel, validator
|
||||
|
||||
from modules.apihelper.base import ArtworkImage, PostInfo
|
||||
from modules.apihelper.helpers import get_device_id, get_ds
|
||||
from modules.apihelper.helpers import get_device_id, get_ds, get_ua
|
||||
from modules.apihelper.request.hoyorequest import HOYORequest
|
||||
from utils.typedefs import JSONDict
|
||||
|
||||
@ -366,11 +366,7 @@ class Verification:
|
||||
VERIFY_VERIFICATION_URL = "/game_record/app/card/wapi/verifyVerification"
|
||||
AJAX_URL = "/ajax.php"
|
||||
|
||||
USER_AGENT = (
|
||||
"User-Agent: Mozilla/5.0 (Linux; Android 12; Mi 10 Build/SKQ1.211006.001; wv) "
|
||||
"AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/103.0.5060.129 Mobile Safari/537.36 "
|
||||
"miHoYoBBS/2.36.1"
|
||||
)
|
||||
USER_AGENT = get_ua()
|
||||
BBS_HEADERS = {
|
||||
"Accept": "application/json, text/plain, */*",
|
||||
"Accept-Encoding": "gzip, deflate",
|
||||
|
@ -7,7 +7,7 @@ from genshin import constants, types
|
||||
from genshin.client import routes
|
||||
from genshin.utility import ds
|
||||
|
||||
from modules.apihelper.helpers import get_ds, get_headers
|
||||
from modules.apihelper.helpers import get_ds, get_ua, get_device_id
|
||||
from utils.patch.methods import patch, patchable
|
||||
|
||||
|
||||
@ -80,11 +80,12 @@ class BaseClient:
|
||||
}
|
||||
elif region == types.Region.CHINESE:
|
||||
_app_version, _client_type, _ds = get_ds(new_ds=True, data=data, params=params)
|
||||
ua = get_headers(version=_app_version)
|
||||
ua = get_ua(version=_app_version)
|
||||
headers = {
|
||||
"User-Agent": ua,
|
||||
"X_Requested_With": "com.mihoyo.hoyolab",
|
||||
"Referer": "https://webstatic-sea.hoyolab.com",
|
||||
"x-rpc-device_id": get_device_id(ua),
|
||||
"x-rpc-app_version": _app_version,
|
||||
"x-rpc-client_type": _client_type,
|
||||
"ds": _ds,
|
||||
|
Loading…
Reference in New Issue
Block a user