import sqlite3,time,json,datetime,subprocess
DB='/opt/struktur/youtube-research/knowledge.db'; start=datetime.datetime.now(datetime.timezone.utc)
rows=[]
for i in range(36):
c=sqlite3.connect('file:'+DB+'?mode=ro',uri=True); c.row_factory=sqlite3.Row
j=c.execute("select e.job_id,e.video_id,e.youtube_id,e.status,e.step,e.attempts,e.error_code,e.error_message,e.lease_until,v.transcript_status,v.transcript_source,length(trim(coalesce(v.transcript,''))) n from e2e_jobs e join videos v on v.id=e.video_id where e.job_id=275").fetchone(); others=c.execute("select job_id,status,step,attempts from e2e_jobs where job_id<>275 and status='supadata_processing'").fetchall(); c.close(); rows.append({'at':datetime.datetime.now(datetime.timezone.utc).isoformat(),'job':dict(j),'other_processing':[dict(x) for x in others]}); print(json.dumps(rows[-1],ensure_ascii=False),flush=True)
if j['status'] in ('complete','supadata_native_unavailable','video_unavailable','access_restricted','rejected_no_usable_transcript','discarded_after_processing_error'): break
time.sleep(10)
print('FINAL',json.dumps({'start':start.isoformat(),'samples':rows},ensure_ascii=False))