douyinWEB/scripts/_tmp_confirm_only.py
2026-09-13 22:10:49 -05:00

70 lines
2.7 KiB
Python

# -*- coding: utf-8 -*-
"""Read-only confirm: dylive ops + shorts/live; dy only observe (do not enable)."""
from __future__ import annotations
import json
import sys
import http.cookiejar
import urllib.request
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
def call(base, path, opener=None, method="GET", body=None, timeout=45):
data = None if body is None else json.dumps(body).encode()
req = urllib.request.Request(
f"{base}{path}", data=data, method=method, headers={"Content-Type": "application/json"}
)
op = opener or urllib.request.build_opener()
with op.open(req, timeout=timeout) as r:
return json.loads(r.read().decode())
def login(base):
cj = http.cookiejar.CookieJar()
op = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj))
call(base, "/api/auth/login", op, "POST", {"username": "hackrobot", "password": "Xiao4669805@"})
return op
for base in ["https://dylive.nomadro.com", "https://dy.nomadro.com"]:
print(f"\n===== {base} =====")
op = login(base)
h = call(base, "/api/health", op)
print("ops_panel_fields", {
"youtube_ok": (h.get("youtube") or {}).get("ok"),
"youtube_monitor_running": (h.get("youtube_monitor") or {}).get("running"),
"pb_ok": (h.get("pocketbase") or {}).get("ok"),
"s3": h.get("s3"),
"monitor_running": (h.get("monitor") or {}).get("running"),
})
shorts = call(base, "/api/shorts/status", op)
print("shorts", {
"enabled": shorts.get("enabled"),
"running": shorts.get("running"),
"busy": shorts.get("busy"),
"quota_gap": shorts.get("quota_gap"),
"processed": shorts.get("processed"),
"sampled": shorts.get("sampled"),
"active_jobs": shorts.get("active_jobs"),
"last_error": shorts.get("last_error"),
})
ch = call(base, "/api/shorts/channels", op)
rows = ch.get("channels") or []
print("shorts_channels", len(rows), "enabled", sum(1 for r in rows if r.get("enabled")))
relay = call(base, "/api/youtube/relay/status", op)
print("relay", {
"enabled": relay.get("enabled"),
"running": relay.get("running"),
"pushing_count": relay.get("pushing_count"),
"enabled_groups": relay.get("enabled_groups"),
"last_error": relay.get("last_error"),
})
live = call(base, "/api/youtube/live-map", op, timeout=90)
print("live_map", live.get("live_count"), live.get("source"))
try:
pb = call(base, "/api/pb/health", op)
print("pb_health", {"ok": pb.get("ok"), "in_sync": pb.get("in_sync"), "max_abs_delta": pb.get("max_abs_delta")})
except Exception as ex:
print("pb_health ERR", ex)