douyinWEB/scripts/_diag_resolve_room.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

66 lines
1.8 KiB
Python

# -*- coding: utf-8 -*-
"""Diagnose Douyin room resolve on VPS vs local cookie."""
from __future__ import annotations
import sys
import paramiko
if hasattr(sys.stdout, "reconfigure"):
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
HOST = "108.174.50.68"
USER = "root"
PASS = "Xiao4669805"
REMOTE = r"""
cd /opt/douyinWEB/backend && .venv/bin/python - <<'PY'
import asyncio, json
from app.douyin import check_room
from app.db import get_settings_map
cfg = get_settings_map()
cookie = str(cfg.get("dy_cookie") or "")
print("cookie_len", len(cookie.strip()))
print("cookie_head", cookie.strip()[:80].encode("ascii", "replace").decode())
async def main():
r = await check_room("https://live.douyin.com/81002009942", cookie=cookie)
slim = {
"ok": r.get("ok"),
"is_live": r.get("is_live"),
"status": r.get("status"),
"status_code": r.get("status_code"),
"anchor": (r.get("anchor_name") or "")[:40],
"title": (r.get("title") or "")[:40],
"error": r.get("error"),
"risk": r.get("risk"),
"n_cands": len(r.get("stream_candidates") or []),
"raw": r.get("raw"),
}
cands = r.get("stream_candidates") or []
if cands:
slim["cand0"] = str(cands[0])[:140]
print(json.dumps(slim, ensure_ascii=True, indent=2))
asyncio.run(main())
PY
"""
def main() -> None:
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect(HOST, 22, USER, PASS, timeout=45, allow_agent=False, look_for_keys=False)
_stdin, stdout, stderr = c.exec_command(REMOTE, timeout=60)
out = stdout.read().decode("utf-8", errors="replace")
err = stderr.read().decode("utf-8", errors="replace")
print(out)
if err.strip():
print("STDERR:", err[:2000])
c.close()
if __name__ == "__main__":
main()