# -*- coding: utf-8 -*-
import io, sys, os, re, json
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
os.chdir(r"D:\work buddy\2026-11-05-14-15-52")
t=open("index_main.html",encoding="utf-8").read()
seg=t[t.find("const PROGRAMS="):t.find("const CATD=")]
chunks=re.findall(r'\{id:"([^"]+)",[\s\S]*?url:"([^"]+)"\}',seg)
prog_ids={i for i,_ in chunks}
prog_dets={d for _,d in chunks}
print("PROGRAMS",len(chunks))

targets=["up-c0a3bf1","up-c775b37","up-c20664c","up-c1fcccb","up-c4be16d","up-ce5bd50","up-cf3f4bd",
 "uw-cb1d654","uw-c4d7ca5","uw-c435976","uw-cb1705c","uw-c631c40","uw-cc21225",
 "dartmouth-engineering-sciences-ms","yale-personalized-medicine-applied-engineering",
 "notre-aerospace","notre-civil-and-environmental","notre-civil-engineering","notre-interdisciplinary"]
for x in targets:
    hit=[d for d in prog_dets if os.path.basename(d).startswith(x)]
    print(("IN-PROG " if hit else "NEW     "),x,hit)

print("\n== 库内 UW 条目 ==")
for m in re.finditer(r'\{id:"(uw-[^"]+)",[\s\S]*?en:"([^"]*)"[\s\S]*?deg:"([^"]*)"[\s\S]*?dur:"([^"]*)"[\s\S]*?url:"([^"]+)"',seg):
    print(" ",m.group(1),"|",m.group(3),"|",m.group(4)[:30],"|",m.group(2)[:45],"|",os.path.basename(m.group(5)))
