v0.5.84: matches origin filter, mobile gate, refresh reliability.
Ship Web refresh cache/lock, mobile demand gate, matches 职业/国服 filter, and related site updates through 0.5.84. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -5,6 +5,9 @@ For every streamer row with ``live_url`` this script writes:
|
||||
- ``is_live`` — True only when the platform confirms the room is live
|
||||
- ``live_probed_at`` — UTC ISO timestamp of the successful probe
|
||||
|
||||
Probe backend follows the ``live_url`` host (may differ from profile
|
||||
``platform``, e.g. Douyin profile + Bilibili room).
|
||||
|
||||
Approach (verified 2026-07):
|
||||
|
||||
- Bilibili: public API ``api.live.bilibili.com/room/v1/Room/get_info`` with the
|
||||
@@ -155,6 +158,16 @@ def room_ref_from_url(live_url: str) -> str | None:
|
||||
return path.split("/")[0] or None
|
||||
|
||||
|
||||
def live_platform_from_url(live_url: str, fallback: str = "") -> str:
|
||||
"""Probe backend follows the live room host (may differ from profile platform)."""
|
||||
host = urllib.parse.urlparse(live_url.strip()).netloc.lower()
|
||||
if "bilibili.com" in host:
|
||||
return "bilibili"
|
||||
if "douyin.com" in host:
|
||||
return "douyin"
|
||||
return (fallback or "").strip().lower()
|
||||
|
||||
|
||||
def probe_streamers(
|
||||
payload: dict, *, ids: set[str] | None = None
|
||||
) -> tuple[int, int, int]:
|
||||
@@ -172,7 +185,8 @@ def probe_streamers(
|
||||
live_url = str(row.get("live_url") or "").strip()
|
||||
if not live_url:
|
||||
continue
|
||||
platform = str(row.get("platform") or "").strip().lower()
|
||||
fallback = str(row.get("platform") or "").strip().lower()
|
||||
platform = live_platform_from_url(live_url, fallback)
|
||||
ref = room_ref_from_url(live_url)
|
||||
if not ref:
|
||||
print(f"skip {sid}: cannot parse room ref from {live_url!r}", flush=True)
|
||||
@@ -244,10 +258,7 @@ def main() -> int:
|
||||
if args.dry_run:
|
||||
print(f"dry-run: would write {args.out} ({summary})", flush=True)
|
||||
return 0
|
||||
args.out.write_text(
|
||||
json.dumps(payload, ensure_ascii=False, indent=2) + "\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
http_utils.write_json_atomic(args.out, payload)
|
||||
print(f"wrote {args.out} {summary}", flush=True)
|
||||
# Soft-fail for CI/refresh_web: always exit 0 after writing.
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user