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>
41 lines
1.7 KiB
Python
41 lines
1.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
from __future__ import annotations
|
|
import sys
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
CMD = r"""
|
|
cd /opt/douyinWEB/backend
|
|
.venv/bin/python <<'PY'
|
|
from app import youtube_relay_db, yt_assign_db
|
|
from app.youtube_relay_pipeline import _group_in_active_slot
|
|
winner=None
|
|
for g in yt_assign_db.list_groups(include_urls=False, include_secret=False):
|
|
if g.get('has_stream_key') and g.get('enabled') and _group_in_active_slot(str(g.get('id')), keyed_only=True):
|
|
winner=g; break
|
|
st=youtube_relay_db.get_relay_state(str(winner['id'])) or {}
|
|
for line in (st.get('recent_log') or [])[-40:]:
|
|
s=str(line)
|
|
if 'Stream #' in s or 'Audio' in s or 'audio' in s or 'bitrate=' in s or 'a:' in s.lower():
|
|
print(s[:240])
|
|
print('--- last frames ---')
|
|
for line in (st.get('recent_log') or [])[-3:]:
|
|
print(str(line)[:200])
|
|
PY
|
|
# also sample ffmpeg stderr via /proc if possible — can't. Use timeout ffmpeg -t 3 copy probe
|
|
URL=$(tr '\0' ' ' < /proc/$(pgrep -n -f 'ffmpeg.*rtmps.youtube')/cmdline 2>/dev/null | sed -n 's/.* -i \(http[^ ]*\).*/\1/p')
|
|
echo URL_OK=$( [ -n "$URL" ] && echo yes )
|
|
if [ -n "$URL" ]; then
|
|
timeout 12 ffmpeg -y -loglevel info -rw_timeout 15000000 -reconnect 1 -reconnect_streamed 1 -i "$URL" -t 3 -c:v copy -c:a aac -b:a 128k -ar 48000 -ac 2 -f null - 2>&1 | egrep -i 'Stream #|Audio:|Output|error|bitrate|a:' | head -40
|
|
fi
|
|
"""
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect("108.174.50.68", 22, "root", "Xiao4669805", timeout=60, allow_agent=False, look_for_keys=False)
|
|
_, o, e = c.exec_command(CMD, timeout=90)
|
|
print(o.read().decode("utf-8", "replace"))
|
|
print(e.read().decode("utf-8", "replace")[-1000:])
|
|
c.close()
|