feat(douyu): 完成账号平台阶段一到四并接入最新协议
This commit is contained in:
@@ -46,6 +46,14 @@ def query_elite_user_info(
|
||||
return client.elite_user_info(manual_id=manual_id, rid=rid)
|
||||
|
||||
|
||||
def query_esports_user_info(
|
||||
client: DouyuActivityClient,
|
||||
*,
|
||||
manual_id: str,
|
||||
) -> dict[str, Any]:
|
||||
return client.esports_user_info(manual_id=manual_id)
|
||||
|
||||
|
||||
def query_bind_info(
|
||||
client: DouyuActivityClient,
|
||||
*,
|
||||
@@ -98,6 +106,14 @@ def query_gold_account(client: DouyuActivityClient) -> dict[str, Any]:
|
||||
return client.gold_account()
|
||||
|
||||
|
||||
def query_gold_qr_state(
|
||||
client: DouyuActivityClient,
|
||||
*,
|
||||
token: str,
|
||||
) -> dict[str, Any]:
|
||||
return client.query_gold_qr_state(token)
|
||||
|
||||
|
||||
def query_exchange_balance(client: DouyuActivityClient) -> dict[str, Any]:
|
||||
return client.exchange_balance()
|
||||
|
||||
@@ -157,6 +173,65 @@ def query_points(
|
||||
return client.query_points(uid=uid, ctn=ctn)
|
||||
|
||||
|
||||
def query_points_expirations(
|
||||
client: DouyuActivityClient,
|
||||
*,
|
||||
user_id: str,
|
||||
current: int = 0,
|
||||
page_size: int = 20,
|
||||
) -> dict[str, Any]:
|
||||
return client.query_points_expirations(
|
||||
user_id=user_id,
|
||||
current=current,
|
||||
page_size=page_size,
|
||||
)
|
||||
|
||||
|
||||
def query_points_ledger(
|
||||
client: DouyuActivityClient,
|
||||
*,
|
||||
uid: str,
|
||||
page_num: int = 1,
|
||||
page_size: int = 15,
|
||||
) -> dict[str, Any]:
|
||||
return client.query_points_ledger(
|
||||
uid=uid,
|
||||
page_num=page_num,
|
||||
page_size=page_size,
|
||||
)
|
||||
|
||||
|
||||
def extract_points_expire_time(payload: Any) -> int | None:
|
||||
"""从各层积分响应中提取 willExpireTime(2026-11-21 统一口径)。"""
|
||||
if not isinstance(payload, dict):
|
||||
return None
|
||||
queue: list[dict[str, Any]] = [payload]
|
||||
seen: set[int] = set()
|
||||
while queue:
|
||||
current = queue.pop(0)
|
||||
marker = id(current)
|
||||
if marker in seen:
|
||||
continue
|
||||
seen.add(marker)
|
||||
for key in ("willExpireTime", "will_expire_time"):
|
||||
raw = current.get(key)
|
||||
if raw in (None, "", 0, "0"):
|
||||
continue
|
||||
try:
|
||||
value = int(float(raw))
|
||||
except (TypeError, ValueError, OverflowError):
|
||||
continue
|
||||
if value > 10_000_000_000:
|
||||
value //= 1000
|
||||
if value > 0:
|
||||
return value
|
||||
for key in ("raw", "data", "points_query", "result"):
|
||||
nested = current.get(key)
|
||||
if isinstance(nested, dict):
|
||||
queue.append(nested)
|
||||
return None
|
||||
|
||||
|
||||
def query_limited_goods_result(
|
||||
client: DouyuActivityClient,
|
||||
*,
|
||||
@@ -244,6 +319,7 @@ def query_exchange_orders(
|
||||
|
||||
__all__ = [
|
||||
"activity_client",
|
||||
"extract_points_expire_time",
|
||||
"query_activity_goods",
|
||||
"query_activity_goods_result",
|
||||
"query_bind_info",
|
||||
@@ -252,15 +328,19 @@ __all__ = [
|
||||
"query_esports_bind_info",
|
||||
"query_esports_goods",
|
||||
"query_esports_goods_result",
|
||||
"query_esports_user_info",
|
||||
"query_exchange_balance",
|
||||
"query_exchange_orders",
|
||||
"query_exchange_orders_result",
|
||||
"query_exchange_records",
|
||||
"query_exchange_records_result",
|
||||
"query_gold_account",
|
||||
"query_gold_qr_state",
|
||||
"query_limited_goods",
|
||||
"query_limited_goods_result",
|
||||
"query_points",
|
||||
"query_points_expirations",
|
||||
"query_points_ledger",
|
||||
"query_xpd_bind_info",
|
||||
"query_xpd_embed",
|
||||
"query_xpd_role",
|
||||
|
||||
Reference in New Issue
Block a user