完善虎牙外部单展示、状态恢复与礼包配置
This commit is contained in:
@@ -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 系接口的应用信息。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user