import sys,pandas as pd; sys.path.insert(0,'scripts'); from calls_mech import calls; from subs2txt import load inv=pd.read_csv('results/stream_inventory.csv').set_index('id'); ids=[l.strip() for l in open('data/scale_ids2.txt')]+['gm1ruMjySXY'] rows=[] for v in ids: try: c=calls(v,inv.loc[v,'start_ist']) except FileNotFoundError: print('NOSUBS',v); continue L=load(f'data/subs/{v}.hi-orig.json3') for i,r in enumerate(c): t=r['entry_off_s']; r['cid']=f"{v}#{i}"; r['ctx']=' '.join(x for tt,x in L if t-45<=tt<=t+25)[:330]; rows.append(r) d=pd.DataFrame(rows); d.to_csv('data/candidates.csv',index=False); print(len(d), d.groupby('vid').size().describe())