sh2/d2ypp2/tools/query_host03_recordings.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

75 lines
2.8 KiB
Python

#!/usr/bin/env python3
import paramiko, json
HOST, USER, PASS = "10.88.0.3", "eric", "Xiao4669805"
REMOTE = r'''
import os, glob, time, subprocess
from datetime import datetime
def run(cmd):
return subprocess.check_output(cmd, shell=True, text=True, errors='replace')
print(run("ps aux | grep youtube.py | grep -v grep"))
print(run("ps aux | grep 'ffmpeg.*rtmps' | grep -v grep"))
# recording dirs
for base in ["/opt/live/d2ypp", "/home/eric/d2ypp2-src", "/home/eric"]:
for pat in ["**/download/**", "**/downloads/**", "**/录制/**", "**/*record*/*"]:
for path in glob.glob(base + "/" + pat, recursive=True)[:5]:
if os.path.isdir(path):
print("DIR", path, "files", len(os.listdir(path)[:200]))
# find video files modified between 05:00-08:00 today
hits=[]
for root in ["/opt/live/d2ypp", "/home/eric"]:
for path in glob.glob(root + "/**/*", recursive=True):
try:
if not os.path.isfile(path): continue
if os.path.getsize(path) < 1000: continue
ext=os.path.splitext(path)[1].lower()
if ext not in ['.ts','.flv','.mp4','.mkv','.part']: continue
m=os.path.getmtime(path)
ts=datetime.fromtimestamp(m)
if ts.date().isoformat()=='2026-06-24' and 4 <= ts.hour <= 9:
hits.append((m, path, os.path.getsize(path)))
except: pass
hits.sort(reverse=True)
print('=== video files 04-09 today ===')
for m,p,s in hits[:30]:
print(datetime.fromtimestamp(m).isoformat(), s, p)
# config.ini recording path
for cfg in ["/opt/live/d2ypp/config/config.ini", "/home/eric/d2ypp2-src/config/config.ini"]:
if os.path.exists(cfg):
print('===', cfg, '===')
print(open(cfg, errors='replace').read()[:2500])
# query sqlite for samples with payload containing douyin around morning - broader
import sqlite3
conn=sqlite3.connect('/opt/live/d2ypp/config/hub_state.sqlite')
conn.row_factory=sqlite3.Row
rows=conn.execute(
"SELECT s.ts, s.payload_json, e.process, e.source_room_id "
"FROM youtube_live_samples s JOIN youtube_live_events e ON e.id=s.event_id "
"WHERE s.ts BETWEEN ? AND ? AND e.process='youtube' ORDER BY s.ts",
(time.time()-20*3600, time.time()-10*3600),
).fetchall()
print('samples 10-20h ago', len(rows))
for r in rows[:20]:
print(datetime.fromtimestamp(r['ts']).isoformat(), r['source_room_id'], (r['payload_json'] or '')[:200])
conn.close()
'''
def main():
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)
out = (o.read() + e.read()).decode("utf-8", "replace")[:25000]
import sys
sys.stdout.buffer.write(out.encode("utf-8", "replace") + b"\n")
c.close()
if __name__ == '__main__':
main()