49 lines
1.8 KiB
Python
49 lines
1.8 KiB
Python
#!/usr/bin/env python3
|
|
"""Read-only: cover with cookie only (img behavior)."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
|
|
import httpx
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace", line_buffering=True)
|
|
|
|
BASE = "https://dy.nomadro.com"
|
|
with httpx.Client(follow_redirects=False, timeout=25) as cl:
|
|
r = cl.post(f"{BASE}/api/auth/login", json={"username": "hackrobot", "password": "Xiao4669805@"})
|
|
print("login", r.status_code, "cookie", bool(cl.cookies.get("dy_session")), flush=True)
|
|
print("body keys", list((r.json() or {}).keys()), flush=True)
|
|
rr = cl.get(f"{BASE}/api/sessions")
|
|
print("sessions", rr.status_code, flush=True)
|
|
data = rr.json() if rr.status_code == 200 else {}
|
|
sessions = data.get("sessions") or []
|
|
live = [s for s in sessions if not s.get("ended_at")][:5]
|
|
print("live", len(live), flush=True)
|
|
for s in live:
|
|
sid = s["id"]
|
|
path = f"/api/sessions/{sid}/cover"
|
|
a = cl.get(f"{BASE}{path}")
|
|
print(
|
|
f"{s.get('anchor_name')}: cover_url={s.get('cover_url')!r} "
|
|
f"cookie-get -> {a.status_code} ctype={a.headers.get('content-type')} bytes={len(a.content)}",
|
|
flush=True,
|
|
)
|
|
# absolute s3-style covers among recent
|
|
abs_n = 0
|
|
for s in sessions[:30]:
|
|
for k in ("cover_url", "avatar_url", "cover_proxy_url"):
|
|
u = s.get(k)
|
|
if isinstance(u, str) and u.startswith("http"):
|
|
c = cl.get(u)
|
|
print(f"ABS {k} {u[:90]} -> {c.status_code}", flush=True)
|
|
abs_n += 1
|
|
if abs_n >= 5:
|
|
break
|
|
if abs_n >= 5:
|
|
break
|
|
print("abs_found", abs_n, flush=True)
|
|
d = cl.get("https://dy.nomadro.com/douyin-covers/")
|
|
print("douyin-covers/", d.status_code, flush=True)
|
|
|
|
print("DONE", flush=True)
|