# -*- coding: utf-8 -*-
import 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")

idx = open("index_main.html", encoding="utf-8").read()

# 5 条 PROGRAMS 条目（覆盖已有 CATD 占位 det，不新建 CATD）
entries = [
    '{id:"ut-c0ccb58",s:"ut",n:"教育领导与政策硕士（MA/MEd）",en:"Educational Leadership and Policy (MA/MEd)",dept:"OISE – Educational Leadership and Policy",college:"Ontario Institute for Studies in Education",disc:"edu",lvl:"m",deg:"MA/MEd",dur:"MA 6 sessions / MEd 4–6 sessions",stem:0,rank:"",test:{cls:""},ddl:"",lang:"",tui:"",url:"details/ut-c0ccb58.html"}',
    '{id:"ut-cb5b3c3",s:"ut",n:"音乐表演硕士（MMus）",en:"Music Performance (MMus)",dept:"Faculty of Music – Performance",college:"University of Toronto Faculty of Music",disc:"art",lvl:"m",deg:"MMus",dur:"Sessions（具体待补）",stem:0,rank:"",test:{cls:"notreq"},ddl:"",lang:"",tui:"",url:"details/ut-cb5b3c3.html"}',
    '{id:"ut-c623310",s:"ut",n:"全球职业法律硕士（GPLLM）",en:"Global Professional LLM (GPLLM)",dept:"Faculty of Law – Global Professional LLM",college:"University of Toronto Faculty of Law",disc:"soc",lvl:"m",deg:"GPLLM",dur:"一年制专业型",stem:0,rank:"",test:{cls:""},ddl:"",lang:"",tui:"",url:"details/ut-c623310.html"}',
    '{id:"duke-mape",s:"duke",n:"分析政治经济学硕士（MAPE）",en:"M.A. in Analytical Political Economy",dept:"Economics × Political Science",college:"Trinity College of Arts & Sciences",disc:"soc",lvl:"m",deg:"MA",dur:"30 credits，含资格考试",stem:1,rank:"",test:{cls:""},ddl:"",lang:"",tui:"",url:"details/duke-c294a42.html"}',
    '{id:"nyu-mpa-pnm",s:"nyu",n:"公共与非营利管理与政策硕士（MPA）",en:"MPA in Public and Nonprofit Management and Policy",dept:"Robert F. Wagner Graduate School of Public Service",college:"NYU Wagner",disc:"soc",lvl:"m",deg:"MPA",dur:"45 credits",stem:0,rank:"",test:{cls:""},ddl:"",lang:"",tui:"",url:"details/nyu-c804839.html"}',
]

# PROGRAMS 末条锚点：ut-cdentmsc 后无逗号
anchor = 'url:"details/ut-cdentmsc.html"}\n];'
assert anchor in idx, "PROGRAMS anchor not found"
new_progs = ",\n" + ",\n".join(entries) + "\n"
idx = idx.replace(anchor, 'url:"details/ut-cdentmsc.html"},' + new_progs + '];', 1)

# VD 追加：在 VERIFIED_DETAILS 段末尾 ] 前插入
vd_dets = ['"details/ut-c0ccb58.html"', '"details/ut-cb5b3c3.html"', '"details/ut-c623310.html"',
           '"details/duke-c294a42.html"', '"details/nyu-c804839.html"']
vd_start = idx.find("const VERIFIED_DETAILS=new Set([")
assert vd_start > 0, "VD start not found"
vd_end = idx.find("]);", vd_start)
assert vd_end > vd_start, "VD end not found"
# 在最后一个 ] 前插入
insert = ", " + ", ".join(vd_dets)
idx = idx[:vd_end] + insert + idx[vd_end:]

open("index_main.html", "w", encoding="utf-8").write(idx)
print("APPENDED OK")
