douyinWEB/scripts/_check_room_81002.py
eric d409e416da Ship physical dual-edge stack, Studio CDP live metrics, and ops tooling.
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>
2026-09-04 22:42:40 -05:00

53 lines
1.8 KiB
Python

#!/usr/bin/env python3
import sys
import paramiko
if hasattr(sys.stdout, "reconfigure"):
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
REMOTE = r"""
import asyncio, json, sqlite3
import os
os.chdir('/opt/douyinWEB/backend')
from app.douyin import check_room
from app import db
async def main():
url = 'https://live.douyin.com/81002009942'
cfg = db.get_settings_map()
cookie = str(cfg.get('dy_cookie') or '')
r = await check_room(url, cookie=cookie)
out = {k: r.get(k) for k in ['ok', 'is_live', 'status', 'room_id', 'anchor_name']}
out['stream_url'] = (r.get('stream_url') or '')[:160]
out['candidate_count'] = len(r.get('stream_candidates') or [])
print('check_room:', json.dumps(out, ensure_ascii=False))
for i, u in enumerate((r.get('stream_candidates') or [])[:4]):
print(f' cand[{i}]: {str(u)[:140]}')
c = sqlite3.connect('/opt/douyinWEB/backend/data/monitor.db')
rows = c.execute(
"SELECT room_id, last_status, last_anchor, url FROM rooms "
"WHERE url LIKE '%81002009942%' LIMIT 3"
).fetchall()
print('db_rooms:', rows)
try:
relay = c.execute(
'SELECT group_id, status, substr(stream_input,1,120), substr(error,1,80) '
'FROM youtube_relay_states'
).fetchall()
print('relay_states:', relay)
except Exception as e:
print('relay_err:', e)
asyncio.run(main())
"""
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect("108.174.50.68", 22, "root", "Xiao4669805", timeout=45, allow_agent=False, look_for_keys=False)
_, o, e = c.exec_command(f"/opt/douyinWEB/backend/.venv/bin/python -c {REMOTE!r}", timeout=60)
print(o.read().decode("utf-8", "replace"))
err = e.read().decode("utf-8", "replace").strip()
if err:
print("ERR:", err[:1000])
c.close()