# -*- 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' import subprocess, re, time from app import db, youtube_relay_db, yt_assign_db from app.youtube_relay_pipeline import _group_in_active_slot from app.youtube_relay_presets import resolve_relay_encoding cfg=db.get_settings_map() enc=resolve_relay_encoding(cfg) print('enc_audio', enc.get('audio_bitrate_kbps'), 'preset', enc.get('preset_id')) 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 {} if winner else {} # get input url from running cmdline import os pid=int(st.get('ffmpeg_pid') or 0) url='' if pid: try: cmd=open(f'/proc/{pid}/cmdline','rb').read().decode('utf-8','replace').replace('\0',' ') m=re.search(r'-i (https?://\S+)', cmd) if m: url=m.group(1) except Exception as e: print('proc_err', e) print('pid', pid, 'url', url[:120]) if url: # ffprobe streams p=subprocess.run(['ffprobe','-v','error','-show_streams','-print_format','json', url], capture_output=True, text=True, timeout=25) print('ffprobe_rc', p.returncode) import json try: data=json.loads(p.stdout or '{}') except Exception: data={} print('ffprobe_raw', (p.stdout or '')[:500], (p.stderr or '')[:500]) for s in data.get('streams') or []: print('STREAM', s.get('index'), s.get('codec_type'), s.get('codec_name'), 'ch', s.get('channels'), 'sr', s.get('sample_rate'), 'br', s.get('bit_rate'), 'tags', s.get('tags')) # check recent ffmpeg log for Audio: for line in (st.get('recent_log') or []): if 'Audio' in line or 'audio' in line or 'Stream #' in line: print('LOG', line[:220]) PY """ 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")) err = e.read().decode("utf-8", "replace") if err.strip(): print("STDERR", err[-2000:]) c.close()