#!/usr/bin/env python3 import paramiko, sys, base64 HOST, USER, PASS = "10.88.0.3", "eric", "Xiao4669805" REMOTE = r''' import re path = "/root/.pm2/logs/youtube-out.log" with open(path, "r", errors="replace") as f: lines = f.readlines() def show(title, pred, tail=30): hits = [ln.rstrip() for ln in lines if pred(ln.rstrip())] print(f"\n=== {title} ({len(hits)} hits) ===") for ln in hits[-tail:]: print(ln[:300]) show("2:05 duration", lambda ln: "正在录制 1 路" in ln and "原画 2:05:" in ln, 25) show("07:xx recording", lambda ln: "正在录制 1 路" in ln and "2026-06-24T07:" in ln, 30) show("06:xx with 2h+", lambda ln: "正在录制 1 路" in ln and "2026-06-24T06:" in ln and "原画 2:" in ln, 25) show("05:xx with 2h+", lambda ln: "正在录制 1 路" in ln and "2026-06-24T05:" in ln and "原画 2:" in ln, 25) best = [] for ln in lines: if "正在录制 1 路" not in ln or "2026-06-24T07:1" not in ln: continue m = re.search(r"正在录制 1 路: ([^\[]+)\[原画 ([0-9:]+)\]", ln) if m: best.append((m.group(2), m.group(1).strip())) print("\n=== 07:1x recording names ===") for dur, name in best[-15:]: print(dur, name[:80]) ''' b64 = base64.b64encode(REMOTE.encode()).decode() cmd = f"echo {PASS} | sudo -S python3 -c \"import base64; exec(base64.b64decode('{b64}').decode())\"" c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect(HOST, username=USER, password=PASS, timeout=15) _, o, e = c.exec_command(cmd, timeout=180, get_pty=True) out = (o.read() + e.read()).decode("utf-8", "replace") c.close() sys.stdout.buffer.write(out.encode("utf-8", "replace"))