#!/usr/bin/env python3 """Final smoke: login + active sessions cover fields on both sites.""" from __future__ import annotations import json import ssl import sys import urllib.request from http.cookiejar import CookieJar sys.stdout.reconfigure(encoding="utf-8", errors="replace") CTX = ssl.create_default_context() def probe(site: str): print(f"\n=== {site} ===", flush=True) cj = CookieJar() opener = urllib.request.build_opener( urllib.request.HTTPSHandler(context=CTX), urllib.request.HTTPCookieProcessor(cj), ) body = json.dumps({"username": "hackrobot", "password": "Xiao4669805@"}).encode() req = urllib.request.Request( site + "/api/auth/login", data=body, headers={"Content-Type": "application/json"}, method="POST", ) with opener.open(req, timeout=25) as r: print("login", r.status) with opener.open(site + "/api/sessions/active", timeout=30) as r: data = json.loads(r.read().decode()) items = data.get("sessions") or [] print("active", len(items)) ok_img = 0 for it in items[:8]: cover = (it.get("cover_url") or it.get("cover_proxy_url") or "").strip() avatar = (it.get("avatar_url") or "").strip() src = avatar if avatar.startswith("http") else cover status = "-" if src.startswith("http"): url = src elif src.startswith("/"): url = site + src else: url = "" if url: try: with opener.open(url, timeout=15) as ir: status = f"{ir.status}:{ir.headers.get('content-type','')[:24]}" if ir.status == 200: ok_img += 1 except Exception as e: status = f"ERR:{e}" print( { "id": str(it.get("id") or "")[:8], "avatar": avatar[:60], "cover": cover[:50], "fetch": status, } ) print("ok_img_among_sampled", ok_img) for s in ("https://dylive.nomadro.com", "https://dy.nomadro.live"): probe(s) print("ALL_DONE", flush=True)