完善虎牙外部单展示、状态恢复与礼包配置
This commit is contained in:
@@ -1351,6 +1351,9 @@ class HuyaHttpClient:
|
||||
cookie: str,
|
||||
source_id: str = "yellowcarlist",
|
||||
page_code: str = "heping_baodian_credit_center_page",
|
||||
scene: int = 7,
|
||||
page_id: int = 0,
|
||||
waterfall_tab_id: int | str | None = None,
|
||||
timeout: float = 15.0,
|
||||
*,
|
||||
deep: bool = False,
|
||||
@@ -1366,6 +1369,14 @@ class HuyaHttpClient:
|
||||
req.userId = self._build_shop_user(uid, cookie)
|
||||
req.pageCode = page_code
|
||||
req.appInfo.sourceId = source_id
|
||||
req.appInfo.scene = int(scene or 7)
|
||||
if waterfall_tab_id not in (None, ""):
|
||||
req.blank7 = json.dumps(
|
||||
{"waterfallTabId": str(waterfall_tab_id)},
|
||||
separators=(",", ":"),
|
||||
)
|
||||
req.flag9 = int(page_id or 0)
|
||||
req.flags11 = []
|
||||
resp = self.call_rpc(
|
||||
"PlayMallUI",
|
||||
"queryAllocation",
|
||||
|
||||
@@ -1264,6 +1264,56 @@ def parse_points_center_gifts(payload: dict | None) -> list[dict]:
|
||||
return gifts
|
||||
|
||||
|
||||
def extract_points_center_tabs(payload: dict | None) -> list[dict]:
|
||||
"""从 ``queryAllocation`` 基础响应里提取页签定义。
|
||||
|
||||
真机(2026-11-11 HAR)结构::
|
||||
|
||||
payload.tag2[0].tag0 # pageId,例如 343
|
||||
payload.tag2[0].tag5 # SIMPLE_LIST,内容是分类/页签 LIST
|
||||
→ tag0 waterfallTabId,例如 431 / 433
|
||||
→ tag1 页签名,例如 精英专享 / 限量返场
|
||||
→ tag7 商品数
|
||||
|
||||
基础请求只返回第一个页签的商品;其余页签必须带着这里的 pageId +
|
||||
waterfallTabId 再查一次。因此页签 ID 由响应动态发现,不写死活动值。
|
||||
"""
|
||||
if not isinstance(payload, dict):
|
||||
return []
|
||||
|
||||
result: list[dict] = []
|
||||
seen: set[tuple[int, int]] = set()
|
||||
for section in payload.get("tag2") or []:
|
||||
if not isinstance(section, dict):
|
||||
continue
|
||||
page_id = _as_int(section.get("tag0"))
|
||||
blob = section.get("tag5")
|
||||
if page_id is None or not isinstance(blob, (bytes, bytearray)):
|
||||
continue
|
||||
categories = decode_value_bytes(bytes(blob), max_depth=40, keep_bytes=True)
|
||||
if not isinstance(categories, list):
|
||||
continue
|
||||
for tab in categories:
|
||||
if not isinstance(tab, dict):
|
||||
continue
|
||||
tab_id = _as_int(tab.get("tag0"))
|
||||
if tab_id is None:
|
||||
continue
|
||||
key = (page_id, tab_id)
|
||||
if key in seen:
|
||||
continue
|
||||
seen.add(key)
|
||||
result.append(
|
||||
{
|
||||
"page_id": page_id,
|
||||
"tab_id": tab_id,
|
||||
"name": _as_text(tab.get("tag1"))[:64],
|
||||
"count": _as_int(tab.get("tag7")),
|
||||
}
|
||||
)
|
||||
return result
|
||||
|
||||
|
||||
class PlayMallAppInfo(TafStruct):
|
||||
"""PlayMallUI 系接口的应用信息。
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
import random
|
||||
import re
|
||||
from collections.abc import Callable
|
||||
@@ -1451,6 +1452,9 @@ class HuyaWssClient:
|
||||
cookie: str,
|
||||
source_id: str = "yellowcarlist",
|
||||
page_code: str = POINTS_PAGE_CODE,
|
||||
scene: int = SHOP_APP_SCENE,
|
||||
page_id: int = 0,
|
||||
waterfall_tab_id: int | str | None = None,
|
||||
*,
|
||||
deep: bool = False,
|
||||
):
|
||||
@@ -1464,7 +1468,15 @@ class HuyaWssClient:
|
||||
req = PlayMallQueryAllocationReq()
|
||||
req.userId = self._build_biz_user(uid, cookie)
|
||||
req.appInfo = self._build_play_mall_app(source_id)
|
||||
req.appInfo.scene = int(scene or SHOP_APP_SCENE)
|
||||
req.pageCode = page_code
|
||||
if waterfall_tab_id not in (None, ""):
|
||||
req.blank7 = json.dumps(
|
||||
{"waterfallTabId": str(waterfall_tab_id)},
|
||||
separators=(",", ":"),
|
||||
)
|
||||
req.flag9 = int(page_id or 0)
|
||||
req.flags11 = []
|
||||
if not deep:
|
||||
return await self.call_rpc_raw("PlayMallUI", "queryAllocation", req)
|
||||
body = await self.call_rpc("PlayMallUI", "queryAllocation", req, None)
|
||||
|
||||
Reference in New Issue
Block a user