import json, re

html = open('index_main.html', encoding='utf-8').read()
existing_ids = set(re.findall(r'\{id:"([^"]+)"', html))
existing_urls = set(re.findall(r'url:"(details/[^"]+)"', html))
print('PROGRAMS 已有 id 数:', len(existing_ids))
print('PROGRAMS 已有 url 数:', len(existing_urls))

todo = json.load(open('todo_upgrade.json', encoding='utf-8'))
print('todo_upgrade 总数:', len(todo))
print('todo 字段示例:', list(todo[0].keys()))

# 筛选 UCSD 且未在 PROGRAMS 的
ucsd_pending = []
for t in todo:
    if t.get('s', '') == 'ucsd':
        url = t.get('det', '') or t.get('url', '')
        if not url or url not in existing_urls:
            ucsd_pending.append(t)

print('UCSD pending 数:', len(ucsd_pending))
for i, t in enumerate(ucsd_pending[:30]):
    en = t.get('en', '')[:70]
    cn = t.get('cn', '')[:30]
    deg = t.get('deg', '')
    det = t.get('det', '')[:50]
    disc = t.get('disc', '')
    print(f'  {i+1}. en={en} | cn={cn} | deg={deg} | disc={disc} | det={det}')
