#!/usr/bin/env python3 """生成打码平台请求模板。 """ from __future__ import annotations import argparse import json import sys from typing import Any def configure_utf8_stdio() -> None: for stream in (sys.stdout, sys.stderr): if hasattr(stream, "reconfigure"): stream.reconfigure(encoding="utf-8") configure_utf8_stdio() def template_for(platform: str, captcha_type: str, provider: str) -> dict[str, Any]: base: dict[str, Any] = { "platform": platform, "captcha_type": captcha_type, "provider": provider, "send_request": False, "api_key": "<由用户运行时提供,不要写入文件>", "authorization_required": True, "notes": [ "这是请求模板,不会发送网络请求。", "只用于自有系统或明确授权 QA。", "脚本不读取 API key,不保存凭据。", "不要把 token 注入未授权流程。", ], } token_providers = { "recaptcha", "hcaptcha", "cloudflare-turnstile", "arkose-funcaptcha", "mtcaptcha", "yandex-smartcaptcha", "captchafox", "prosopo-procaptcha", "trustcaptcha", } if captcha_type in {"text", "math"}: base["payload"] = { "method": "image", "image": "", "constraints": {"charset": "", "length": "", "case_sensitive": False}, } elif captcha_type in { "click-select", "grid", "area-select", "difference-click", "font-identify", "semantic-reasoning", }: base["payload"] = { "method": "coordinates", "image": "", "prompt": "<题面文本>", "coordinate_space": "image", "expected_output": "ordered_points_or_grid_indexes", } elif captcha_type in {"slider", "rotate", "image-restore"}: base["payload"] = { "method": "image_or_slider", "background": "", "piece": "", "screenshot": "", "expected_output": "offset_or_angle", } elif captcha_type == "audio": base["payload"] = { "method": "audio", "audio": "