统一虎牙 App 登录设备画像

This commit is contained in:
yml2213
2026-08-30 23:04:28 +08:00
parent bc02018719
commit f4ed518b50
6 changed files with 281 additions and 119 deletions
+18
View File
@@ -19,6 +19,7 @@ import hashlib
import json
import os
import random
from collections.abc import Mapping
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent.parent
@@ -48,6 +49,23 @@ APP_VERSION = "13.4.22"
SDK_VERSION = "1.0.80138"
def mobile_user_agent(device_info: Mapping[str, object]) -> str:
"""根据统一设备画像生成 App WebView UA。"""
screen = str(device_info.get("screen") or "")
parts = screen.split(",")
android_ver = parts[2] if len(parts) >= 3 and parts[2] else "11"
api_level = parts[1] if len(parts) >= 2 and parts[1] else "30"
model = str(device_info.get("model") or "M2102J2SC")
vendor = str(device_info.get("vendor") or "android")
app_version = str(device_info.get("app_version") or APP_VERSION)
return (
f"Mozilla/5.0 (Linux; Android {android_ver}; {model} "
"Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) "
f"Version/4.0 Chrome/149.0.7827.159 Mobile Safari/537.36 huya adr/"
f"{app_version}/{vendor}/{api_level}"
)
def _rand_sha1_hex() -> str:
return hashlib.sha1(os.urandom(20)).hexdigest()