fix(huya): 为精英宝典兑换接入代理

This commit is contained in:
yml
2026-11-13 19:17:13 +08:00
parent 711be0e2b6
commit 563b32b7b7
5 changed files with 374 additions and 10 deletions
+19 -2
View File
@@ -40,7 +40,10 @@ class GoodsMixin:
def _push_log(self, level: str, message: str) -> None: ...
def _activity_client(self, uid: int, cookie: str): ...
def _shop_client(self, uid: int, cookie: str): ...
def _http_client(self): ...
def _http_client(self, proxies: dict[str, str] | None = None): ...
def _exchange_proxies(
self,
) -> tuple[dict[str, str] | None, str, str]: ...
def _probe_bind_status(
self, uid: int, cookie: str, b_act_id_int: int, outer_act_id: str = ""
): ...
@@ -444,7 +447,19 @@ class GoodsMixin:
pay_channel = self._normalize_pay_channel(
self.payload.get("pay_channel") or config_info.get("pay_channel")
)
client: Any = self._http_client()
proxies, proxy_source, proxy_error = self._exchange_proxies()
if proxy_error:
self._mark_task(
worker_db,
task,
"failed",
f"兑换代理不可用:{proxy_error}",
{"proxy_used": False, "proxy_source": "error"},
)
return
if proxies:
self._push_log("info", f"[{uid}] 兑换任务使用代理: {proxy_source}")
client: Any = self._http_client(proxies=proxies)
prepared = prepare_exchange(
client,
uid=uid,
@@ -464,6 +479,8 @@ class GoodsMixin:
"redeem_state": prepared.state.to_dict() if prepared.state else None,
"target": prepared.target,
"exchange_plan": prepared.plan,
"proxy_used": bool(proxies),
"proxy_source": proxy_source,
}
if prepared.status == EXCHANGE_STATUS_EXCHANGED:
result = {