"""Shared browser response value objects and challenge detection.""" from __future__ import annotations from dataclasses import dataclass @dataclass(frozen=True) class BrowserResponse: status: int body: str challenge: str = "" @dataclass(frozen=True) class BrowserMediaResponse: status: int content_type: str body_base64: str @dataclass(frozen=True) class BrowserLoginQRResponse: content_type: str body_base64: str qr_detected: bool def detect_challenge(status: int, body: str) -> str: if status == 429: return "" if status == 412: return "captcha" lowered = body.lower() if any(token in lowered for token in ("captcha", "verify_code", "验证码")): return "captcha" if any(token in lowered for token in ("device_verify", "device_check", "设备验证")): return "device" return ""