#!/usr/bin/env python3 """Find youtube.py log output and room at ~07:00 on host03.""" from __future__ import annotations import paramiko HOST, USER, PASS = "10.88.0.3", "eric", "Xiao4669805" REMOTE = r''' import os, glob, re, time from datetime import datetime # find non-empty logs modified today candidates = [] for root in ["/opt/live/d2ypp", "/home/eric/d2ypp2-src", "/tmp", "/var/log"]: for path in glob.glob(root + "/**/*", recursive=True): try: if not os.path.isfile(path): continue if os.path.getsize(path) == 0: continue mtime = os.path.getmtime(path) if mtime < time.time() - 48*3600: continue if any(x in path.lower() for x in ["youtube", "ffmpeg", "streamget", "playurl", "pm2", "douyin", "record"]): candidates.append((mtime, path, os.path.getsize(path))) except Exception: pass candidates.sort(reverse=True) print("=== recent log-like files ===") for mtime, path, size in candidates[:40]: print(datetime.fromtimestamp(mtime).isoformat(), size, path) # grep morning recordings in likely logs patterns = ["正在录制", "录制 1 路", "YOUTUBE", "live.douyin.com/288944", "live.douyin.com/629587", "live.douyin.com/334176"] for mtime, path, size in candidates[:25]: if size > 50_000_000: continue try: with open(path, "r", errors="replace") as f: hits = [] for line in f: if "2026-06-24T0" in line or "2026-06-24 0" in line: if any(p in line for p in patterns) or "live.douyin.com" in line: if "06:" in line or "07:" in line or "05:" in line: hits.append(line.rstrip()) if hits: print(f"\n=== {path} morning hits {len(hits)} ===") for line in hits[-40:]: print(line[:350]) except Exception: pass # systemd for youtube if any os.system("systemctl list-units '*youtube*' '*live*' 2>/dev/null | head -20") ''' def main() -> int: 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(f"python3 - <<'PY'\n{REMOTE}\nPY", timeout=180, get_pty=True) print((o.read() + e.read()).decode("utf-8", "replace")[:30000]) c.close() return 0 if __name__ == "__main__": raise SystemExit(main())