sh2/d2ypp2/tools/read_host03_youtube_log_probe.py
eric 278b48497e Add YouTube relay log tooling and optional hub service controls.
This captures the current live stack updates across the API, Linux service scripts, tests, diagnostics, and exported console assets so the Ubuntu deployment can pull a consistent test3 build.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-30 05:10:09 -05:00

43 lines
1.5 KiB
Python

#!/usr/bin/env python3
import paramiko, sys, base64
HOST, USER, PASS = "10.88.0.3", "eric", "Xiao4669805"
REMOTE = r'''
path = "/root/.pm2/logs/youtube-out.log"
with open(path, "r", errors="replace") as f:
lines = f.readlines()
print('total lines', len(lines))
# sample lines with 录制
hits=[ln for ln in lines if '录制' in ln]
print('lines with 录制', len(hits))
for ln in hits[:5]:
print('SAMPLE', repr(ln[:200]))
for ln in hits[-5:]:
print('TAIL', repr(ln[:200]))
# unique date prefixes today
from collections import Counter
c=Counter()
for ln in lines:
if ln.startswith('2026-06-24'):
c[ln[:13]] += 1
print('date prefixes', dict(c))
# any line with 2:05
h2=[ln for ln in lines if '2:05' in ln and '录制' in ln]
print('2:05 recording lines', len(h2))
for ln in h2[-10:]:
print(ln[:250])
# lines at hour 07
h7=[ln for ln in lines if '2026-06-24' in ln and ('T07:' in ln or ' 07:' in ln) and '录制' in ln]
print('hour07 recording', len(h7))
for ln in h7[-15:]:
print(ln[:250])
'''
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"))