Capture Neko/WG/network hubs, Studio viewer charts, physical deploy docs, and one-shot scripts so VPS vs physical can be toggled later without losing WIP. Co-authored-by: Cursor <cursoragent@cursor.com>
60 lines
1.6 KiB
Python
60 lines
1.6 KiB
Python
# -*- coding: utf-8 -*-
|
|
import asyncio
|
|
import sys
|
|
import traceback
|
|
|
|
sys.path.insert(0, "/opt/douyinWEB/backend")
|
|
|
|
from app import youtube_live, youtube_neko, yt_assign_db # noqa: E402
|
|
|
|
|
|
async def main() -> None:
|
|
groups = yt_assign_db.list_groups(include_urls=False)
|
|
print("groups", len(groups))
|
|
for g in groups:
|
|
nid = int(g.get("neko_instance_id") or 0)
|
|
if nid < 1:
|
|
continue
|
|
try:
|
|
snap = youtube_neko.studio_on_air_lookup(nid, max_age_sec=180.0)
|
|
except Exception:
|
|
traceback.print_exc()
|
|
continue
|
|
print(
|
|
"neko",
|
|
nid,
|
|
g.get("name"),
|
|
"page",
|
|
snap.get("live_page_open"),
|
|
"air",
|
|
snap.get("on_air"),
|
|
"src",
|
|
snap.get("detect_source"),
|
|
"url",
|
|
(snap.get("url") or "")[:70],
|
|
"status",
|
|
snap.get("live_status"),
|
|
)
|
|
|
|
try:
|
|
payload = await youtube_live.build_live_map(force=True)
|
|
except Exception:
|
|
traceback.print_exc()
|
|
return
|
|
entries = payload.get("entries") or {}
|
|
live = {
|
|
k: v
|
|
for k, v in entries.items()
|
|
if isinstance(v, dict)
|
|
and v.get("is_live")
|
|
and (k.startswith("assign:") or k.startswith("shorts:") or k.startswith("group:"))
|
|
}
|
|
print("live_count", payload.get("live_count"), "svc_error", payload.get("svc_error"))
|
|
print("live_keys", sorted(live.keys()))
|
|
for k, v in sorted(live.items()):
|
|
print(k, "src=", v.get("source"), "title=", (v.get("title") or "")[:50])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|