虎牙精英宝典
This commit is contained in:
@@ -31,6 +31,52 @@ class GoodsMixin:
|
||||
def _wait_until(self, when: datetime, uid: int) -> bool: ...
|
||||
def _parse_scheduled_time(self, value: Any) -> datetime | None: ...
|
||||
|
||||
def _execute_query_act_tasks(
|
||||
self,
|
||||
worker_db: Session,
|
||||
task: HuyaTask,
|
||||
account: HuyaAccount,
|
||||
account_info: dict,
|
||||
config_info: dict,
|
||||
):
|
||||
"""读取精英宝典任务详情,供专用工作台展示购买/观看任务。"""
|
||||
uid = self._resolve_uid(account_info)
|
||||
cookie = account_info.get("cookie") or ""
|
||||
if not uid or not cookie:
|
||||
self._mark_task(worker_db, task, "failed", "账号 UID 或 Cookie 为空")
|
||||
return
|
||||
act_id = self._to_int(self.payload.get("act_id") or 25135)
|
||||
if not act_id:
|
||||
self._mark_task(worker_db, task, "failed", "精英宝典活动 ID 无效")
|
||||
return
|
||||
client: Any = HuyaHttpClient(
|
||||
logger=lambda msg: self._push_log("info", f"[{uid}] {msg}")
|
||||
)
|
||||
response = client.get_act_task_detail(uid=uid, cookie=cookie, act_id=act_id)
|
||||
if response is None:
|
||||
self._mark_task(worker_db, task, "error", "虎牙活动任务接口无响应")
|
||||
return
|
||||
result = response.to_dict()
|
||||
result["act_id"] = act_id
|
||||
if response.status != 200:
|
||||
self._mark_task(
|
||||
worker_db,
|
||||
task,
|
||||
"failed",
|
||||
response.msg or f"虎牙活动任务查询失败: {response.status}",
|
||||
result,
|
||||
)
|
||||
return
|
||||
account.status = "tasks_queried"
|
||||
account.updated_at = datetime.now(UTC)
|
||||
self._mark_task(
|
||||
worker_db,
|
||||
task,
|
||||
"success",
|
||||
f"已读取 {len(result.get('tasks', []))} 项精英宝典任务",
|
||||
result,
|
||||
)
|
||||
|
||||
def _execute_query_points(
|
||||
self,
|
||||
worker_db: Session,
|
||||
|
||||
Reference in New Issue
Block a user