Ship zombie reconcile, S3 covers, session end/drill-down, rooms ops, and refresh README for production. Co-authored-by: Cursor <cursoragent@cursor.com>
59 lines
2.2 KiB
Python
59 lines
2.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
import paramiko
|
|
|
|
SCRIPT = r'''
|
|
import sys, asyncio, json
|
|
sys.path.insert(0, "/opt/douyinWEB/backend")
|
|
from app.douyin import check_room, _fetch_web_enter
|
|
from app import db
|
|
import httpx
|
|
|
|
cfg = db.get_settings_map()
|
|
cookie = str(cfg.get("dy_cookie") or "")
|
|
rows = db.list_rooms(limit=5, status="live") if hasattr(db, "list_rooms") else None
|
|
|
|
import sqlite3
|
|
conn = sqlite3.connect("/opt/douyinWEB/backend/data/monitor.db")
|
|
conn.row_factory = sqlite3.Row
|
|
r = conn.execute("SELECT url, room_id, last_anchor FROM rooms WHERE last_status='live' LIMIT 1").fetchone()
|
|
print("room", dict(r) if r else None)
|
|
if not r:
|
|
raise SystemExit(0)
|
|
|
|
async def main():
|
|
res = await check_room(r["url"], cookie=cookie)
|
|
print("probe is_live", res.get("is_live"), "has_stream", bool(res.get("stream_url")))
|
|
async with httpx.AsyncClient(timeout=20, verify=False, trust_env=False) as client:
|
|
room = await _fetch_web_enter(client, r["room_id"], cookie=cookie)
|
|
print("room_top_keys", sorted(list(room.keys()))[:50])
|
|
for k in ["cover", "cover_url", "origin_cover", "share_url", "keyframe_image"]:
|
|
if k in room:
|
|
print(k, json.dumps(room.get(k), ensure_ascii=False)[:300])
|
|
owner = room.get("owner") or {}
|
|
print("owner_type", type(owner).__name__)
|
|
if isinstance(owner, dict):
|
|
print("owner_keys", list(owner.keys())[:40])
|
|
for k in ["avatar_thumb", "avatar_medium", "avatar_large", "nickname"]:
|
|
print("owner", k, json.dumps(owner.get(k), ensure_ascii=False)[:250])
|
|
stream = room.get("stream_url") or {}
|
|
if isinstance(stream, dict):
|
|
print("stream_keys", list(stream.keys())[:25])
|
|
flv = stream.get("flv_pull_url") or {}
|
|
print("flv_keys", list(flv.keys())[:10] if isinstance(flv, dict) else flv)
|
|
|
|
asyncio.run(main())
|
|
'''
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect("107.173.30.245", 22, "root", "Xiao4669805", timeout=30, allow_agent=False, look_for_keys=False)
|
|
_, o, e = c.exec_command(
|
|
"/opt/douyinWEB/backend/.venv/bin/python - <<'PY'\n" + SCRIPT + "\nPY",
|
|
timeout=90,
|
|
)
|
|
print(o.read().decode("utf-8", "replace"))
|
|
err = e.read().decode("utf-8", "replace")
|
|
if err.strip():
|
|
print("ERR", err[-2000:])
|
|
c.close()
|