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>
71 lines
2.9 KiB
Python
71 lines
2.9 KiB
Python
# -*- coding: utf-8 -*-
|
|
import json
|
|
import sys
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
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)
|
|
PY = "/opt/douyinWEB/backend/.venv/bin/python"
|
|
remote = r'''
|
|
import json, os, sys
|
|
sys.path.insert(0, "/opt/douyinWEB/backend")
|
|
os.chdir("/opt/douyinWEB/backend")
|
|
from app import db, tiktok_db
|
|
from app.timeutil import push_date_from_ts
|
|
import time
|
|
cfg = db.get_settings_map()
|
|
keys = [
|
|
"shorts_enabled","shorts_live_sample","shorts_sample_any_live","shorts_live_sample_batch",
|
|
"shorts_dedupe_room_day","tiktok_enabled","tiktok_live_sample","tiktok_sample_any_live",
|
|
"tiktok_live_sample_batch","tiktok_dedupe_room_day","tiktok_clip_sec","shorts_clip_sec",
|
|
]
|
|
print("SETTINGS")
|
|
for k in keys:
|
|
print(f" {k}={cfg.get(k)}")
|
|
day = push_date_from_ts(time.time())
|
|
print("DAY", day)
|
|
rooms = db.list_live_douyin_rooms_for_shorts(limit=400)
|
|
print("LIVE", len(rooms))
|
|
for r in rooms[:12]:
|
|
print(" ", r.get("last_anchor") or r.get("last_title") or "", r.get("room_id"), "sid", bool(r.get("active_session_id")))
|
|
used_s = db.room_ids_with_shorts_job_today(day)
|
|
print("SHORTS_USED_TODAY", len(used_s), list(used_s)[:15])
|
|
print("SHORTS_CH", len(db.list_shorts_channels(enabled=True)), "pick", bool(db.pick_shorts_channel(day, cfg)))
|
|
chs = tiktok_db.list_tiktok_channels(enabled=True)
|
|
print("TIKTOK_CH", [(c.get("name"), c.get("enabled"), c.get("oauth_ok")) for c in chs])
|
|
print("TIKTOK_PICK", bool(tiktok_db.pick_tiktok_channel(day)))
|
|
from app import tiktok_session
|
|
for c in chs:
|
|
print(" session", c.get("name"), tiktok_session.channel_has_session(c))
|
|
# jobs today
|
|
import sqlite3
|
|
conn = sqlite3.connect("/opt/douyinWEB/backend/data/monitor.db")
|
|
conn.row_factory = sqlite3.Row
|
|
print("TIKTOK_JOBS_TODAY")
|
|
for row in conn.execute("SELECT status, count(*) n FROM tiktok_jobs WHERE push_date=? GROUP BY status", (day,)):
|
|
print(" ", dict(row))
|
|
print("SHORTS_JOBS_TODAY")
|
|
for row in conn.execute("SELECT status, count(*) n FROM shorts_jobs WHERE push_date=? GROUP BY status", (day,)):
|
|
print(" ", dict(row))
|
|
# overlap live vs used
|
|
live_ids = [str(r.get("room_id") or "") for r in rooms]
|
|
print("LIVE_ALREADY_SHORTS", sum(1 for i in live_ids if i in used_s))
|
|
tt_used = set()
|
|
for row in conn.execute("SELECT DISTINCT room_id FROM tiktok_jobs WHERE push_date=? AND room_id!='' AND status NOT IN ('failed','skipped')", (day,)):
|
|
tt_used.add(row["room_id"])
|
|
print("LIVE_ALREADY_TIKTOK", sum(1 for i in live_ids if i in tt_used), "tt_used", len(tt_used))
|
|
conn.close()
|
|
'''
|
|
sftp = c.open_sftp()
|
|
with sftp.file("/tmp/_sample_diag.py", "w") as f:
|
|
f.write(remote)
|
|
sftp.close()
|
|
_s, out, err = c.exec_command(f"{PY} /tmp/_sample_diag.py", timeout=30)
|
|
print(out.read().decode("utf-8", "replace"))
|
|
e = err.read().decode("utf-8", "replace")
|
|
if e:
|
|
print("ERR:", e[-1500:])
|
|
c.close()
|