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_set = set(re.findall(r'"(details/[^"]+\.html)"', m.group(1)))

prog_sec = re.search(r'const PROGRAMS\s*=\s*\[[\s\S]*?\];', html)
prog_det = set(re.findall(r'url:"(details/[^"]+\.html)"', prog_sec.group(0)))

# 已排除清单（历史定性）
excluded_keywords = [
    'online', 'residency online', 'part-time', 'executive', 'evening',
    'phd-only', 'not terminal', 'combined degree', 'dual', 'teacher',
    'teaching', 'mscf', 'mba'
]

for target in ['nyu', 'uchicago', 'rice', 'vanderbilt', 'emory', 'brown', 'dartmouth']:
    print(f'\n=== {target} MS 候选（非PhD/非已排除） ===')
    cnt = 0
    for t in todo:
        if t['s'] != target:
            continue
        if t['deg'] in ('PhD', 'DMA', 'DrPH'):
            continue
        det = t.get('det', '')
        if det in vd_set or det in prog_det:
            continue
        en_lower = t['en'].lower()
        if any(k in en_lower for k in excluded_keywords):
            continue
        print(f"  {t['cn']} ({t['en']}) - {t['deg']} - {det}")
        cnt += 1
        if cnt >= 6:
            break
