# -*- coding: utf-8 -*-
import sys, io, re
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
BASE = r"D:\work buddy\2026-11-05-14-15-52"
s = open(BASE + r"\index_main.html", encoding="utf-8").read()
a = s.index("const PROGRAMS=[")
b = s.index("const CATD=[")
seg = s[a:b]
blocks = re.findall(r'\{id:"([^"]+)"([\s\S]*?)(?=\}\s*,?\s*\{id:"|\}\s*\]|,?\s*\];)', seg)

def field(t, k):
    m = re.search(k + r':"([^"]*)"', t)
    return m.group(1) if m else ""

rows = []
for pid, body in blocks:
    if not pid.startswith("ucsd"):
        continue
    n = field(body, "n"); en = field(body, "en"); lvl = field(body, "lvl")
    deg = field(body, "deg"); tui = field(body, "tui"); test = field(body, "test")
    rows.append((pid, lvl, deg, n, tui))

print("UCSD total:", len(rows))
miss = [r for r in rows if not r[4] or "待补" in r[4]]
print("缺 tui:", len(miss))
from collections import Counter
print(Counter([r[1] for r in miss]))
for r in miss:
    print(r[0], "|", r[1], "|", r[2], "|", r[3], "|", r[4][:40])
