# -*- coding: utf-8 -*-
import io, sys, re
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
idx=open("index_main.html",encoding="utf-8").read()

# 我新追加的重复条目（简短版），精确匹配
dup = '{id:"ut-cs-msc",s:"ut",n:"计算机科学硕士（MSc）",en:"Master of Science in Computer Science",dept:"Department of Computer Science",college:"Faculty of Arts & Science",disc:"cs",lvl:"m",deg:"MSc",dur:"研究型硕士（thesis）",stem:0,rank:"",test:{cls:"notreq"},ddl:"待补（SGS 项目页）",lang:"待补（TOEFL/IELTS 最低分）",tui:"打包学费待补",url:"details/ut-c863142.html"},'
assert dup in idx, "dup not found"
idx = idx.replace(dup, "", 1)
open("index_main.html","w",encoding="utf-8").write(idx)
print("REMOVED dup. size:", len(idx))

# 确认旧条目 url 指向
seg=idx[idx.find("const PROGRAMS="):idx.find("const CATD=")]
m=re.search(r'\{id:"ut-cs-msc".*?url:"([^"]+)"', seg, re.S)
if m: print("旧 ut-cs-msc url:", m.group(1))
