统一虎牙 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
+5 -7
View File
@@ -6,10 +6,10 @@
from __future__ import annotations
import json
import shutil
import subprocess
import tempfile
import json
from collections.abc import Mapping
from dataclasses import dataclass
from pathlib import Path
@@ -17,6 +17,8 @@ from pathlib import Path
import requests
from loguru import logger
from .device_profile import mobile_user_agent
FINGERPRINT_DIR = Path(__file__).parent / "fingerprint"
RUNNER_JS = FINGERPRINT_DIR / "runner.js"
SDID_PREFIX = "__SDID__"
@@ -75,6 +77,7 @@ def _run_node_runner(
capture_output=True,
text=True,
timeout=total_timeout,
check=False,
cwd=str(FINGERPRINT_DIR),
)
except subprocess.TimeoutExpired as exc:
@@ -123,12 +126,7 @@ def write_device_hint(state_dir: str | Path, device_info: Mapping) -> Path:
screen = str(device_info.get("screen", ""))
parts = screen.split(",")
android_ver = parts[2] if len(parts) >= 3 else "11"
ua = (
f"Mozilla/5.0 (Linux; Android {android_ver}; {device_info.get('model', '')} "
"Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) "
"Version/4.0 Chrome/149.0.7827.159 Mobile Safari/537.36 "
f"huya adr/13.4.22/{device_info.get('vendor', 'android')}/30"
)
ua = mobile_user_agent(device_info)
hint = {
"model": device_info.get("model", ""),
"vendor": device_info.get("vendor", "android"),