#!/usr/bin/env python3 """Read-only: does /api/sessions/.../cover work with cookie only (like )?""" 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, "set-cookie", r.headers.get("set-cookie", "")[:120], flush=True) print("cookies", cl.cookies.jar, flush=True) # list live sessions with bearer from body AND cookies body = r.json() token = body.get("token") or "" rr = cl.get(f"{BASE}/api/sessions", headers={"Authorization": f"Bearer {token}"}) sessions = (rr.json() or {}).get("sessions") or [] live = [s for s in sessions if not s.get("ended_at")][:3] print("live", len(live), flush=True) for s in live: sid = s["id"] path = f"/api/sessions/{sid}/cover" # cookie only a = cl.get(f"{BASE}{path}") print(f"cookie-only {path} -> {a.status_code} ctype={a.headers.get('content-type')} len={len(a.content)}", flush=True) # no cookie no auth with httpx.Client(timeout=15) as bare: b = bare.get(f"{BASE}{path}") print(f"anon {path} -> {b.status_code}", flush=True) # s3-style if any absolute for k in ("cover_url", "avatar_url", "cover_proxy_url"): u = s.get(k) if u and str(u).startswith("http"): c = cl.get(u) print(f"abs {k} {u[:80]} -> {c.status_code}", flush=True) # douyin-covers probe via API-derived public urls if health s3 public_base used # try list objects? skip print("douyin-covers sample", flush=True) d = cl.get("https://dy.nomadro.com/douyin-covers/") print("douyin-covers/", d.status_code, flush=True) print("DONE", flush=True)