# -*- coding: utf-8 -*-
import json, io, sys, os, re
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
os.chdir(r"D:\work buddy\2026-11-05-14-15-52")
todo = json.load(open("todo_upgrade.json", encoding="utf-8"))
idx = open("index_main.html", encoding="utf-8").read()
prog_seg = idx[idx.find("const PROGRAMS="):idx.find("const CATD=")]
existing_dets = set(re.findall(r'url:"(details/[^"]+)"', prog_seg))
# 热门 disc 未入库，按学校分组
hot = [t for t in todo if t["det"] not in existing_dets and t.get("disc") in ("cs","biz","sci") and t["deg"]!="PhD"]
from collections import Counter
c = Counter(t["s"] for t in hot)
print("热门未入库(硕)按校:", dict(c.most_common(15)))
print()
# 看 USC 热门
for t in hot:
    if t["s"]=="usc":
        print("USC:", t["deg"], "|", t["en"], "|", t["det"], "|", t["url"])
