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

56 lines
2.4 KiB
Python

#!/usr/bin/env python3
import paramiko, json
HOST, USER, PASS = "10.88.0.3", "eric", "Xiao4669805"
REMOTE = r'''
import sqlite3, json, re
from datetime import datetime
conn=sqlite3.connect("/opt/live/d2ypp/config/hub_state.sqlite")
conn.row_factory=sqlite3.Row
# search snapshots for morning recording lines
rows=conn.execute("SELECT id, process, source_room_id, started_at, ended_at, duration_seconds, snapshot_json FROM youtube_live_events WHERE process='youtube' ORDER BY id DESC LIMIT 10").fetchall()
for r in rows:
snap=r['snapshot_json'] or ''
if '2026-06-24' in snap or r['id']==67:
print('EVENT', r['id'], 'room', r['source_room_id'], 'dur', r['duration_seconds'])
# extract recording lines
for line in snap.split('\\n'):
if '正在录制' in line or '录制 1 路' in line or '2026-06-24T0' in line:
if any(h in line for h in ['05:','06:','07:','08:']):
print(' ', line[:250])
# search all snapshots for 2:05 or 2:04 or 2:06 duration patterns
print('\n=== snapshot search 2:0x duration ===')
rows2=conn.execute("SELECT id, process, source_room_id, snapshot_json FROM youtube_live_events WHERE snapshot_json LIKE '%2:0%' OR snapshot_json LIKE '%2:1%' OR snapshot_json LIKE '%2:05%'").fetchall()
for r in rows2:
snap=r['snapshot_json']
for pat in [r'\[原画 2:0[0-9]:[0-9]{2}\]', r'\[原画 2:1[0-9]:[0-9]{2}\]', r'2:05:', r'2:04:', r'2:06:']:
m=re.search(pat, snap)
if m:
print('id', r['id'], 'room', r['source_room_id'], 'match', m.group(0))
# context
idx=snap.find(m.group(0))
print(snap[max(0,idx-120):idx+120])
# fetch current status recent_log recording lines
import urllib.request
st=json.loads(urllib.request.urlopen('http://127.0.0.1:8001/status?process=youtube', timeout=20).read())
log=st.get('recent_log','')
print('\n=== current recording lines ===')
for line in log.split('\n'):
if '正在录制' in line or '录制 1 路' in line or '原画' in line:
print(line[: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=90, get_pty=True)
import sys; sys.stdout.buffer.write((o.read()+e.read())[:30000])
c.close()
if __name__=='__main__': main()