import json, re

todo = json.load(open('todo_upgrade.json', encoding='utf-8'))
html = open('index_main.html', encoding='utf-8').read()

m = re.search(r'VERIFIED_DETAILS\s*=\s*new Set\(\[([\s\S]*?)\]\)', html)
vd_raw = m.group(1) if m else ''
vd_set = set(re.findall(r'"(details/[^"]+\.html)"', vd_raw))

# 已在 PROGRAMS 的 det 路径
prog_sec = re.search(r'const PROGRAMS\s*=\s*\[[\s\S]*?\];', html)
prog_txt = prog_sec.group(0) if prog_sec else ''
prog_det = set(re.findall(r'url:"(details/[^"]+\.html)"', prog_txt))
print('PROGRAMS 里 url 数:', len(prog_det))

# 按学校看候选
for target in ['gatech', 'caltech', 'notre', 'uva', 'unc']:
    print(f'\n=== {target} 候选 ===')
    cnt = 0
    for t in todo:
        if t['s'] != target:
            continue
        det = t.get('det', '')
        if det in vd_set or det in prog_det:
            continue
        # 排除 PhD 除非明确要
        if t['deg'] in ('PhD', 'DMA'):
            continue
        print(f"  {t['cn']} ({t['en']}) - {t['deg']} - {det}")
        cnt += 1
        if cnt >= 8:
            break
