# -*- coding: utf-8 -*-
import io, sys, os, json, re, datetime
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
os.chdir(r"D:\work buddy\2026-11-05-14-15-52")
b=json.load(open("_heartbeat_baseline.json",encoding="utf-8"))
idx=open("index_main.html",encoding="utf-8").read()
seg=idx[idx.find("const PROGRAMS="):idx.find("const CATD=")]
lvl=re.findall(r'lvl:"([^"]+)"',seg)
vd=re.findall(r'"([^"]+\.html)"',idx[idx.find("const VERIFIED_DETAILS="):])
details=len([f for f in os.listdir("details") if f.endswith(".html")])
mt=datetime.datetime.fromtimestamp(os.path.getmtime("index_main.html")).strftime("%Y-%m-%d %H:%M:%S")

b["updated_at"]=mt
b["index_main_mtime"]=mt
b["schools"]=36
b["programs"]=len(lvl)
b["programs_master"]=lvl.count("m")
b["programs_phd"]=lvl.count("d")
b["catd"]=2676
b["dead_links"]=0
b["excluded_residue"]=0
b["vd_set"]=len(set(vd))
b["details_html"]=details
b["node_check"]="exit 0"

new_pending=[
 "details/mit-supply-chain-management-residential.html 浏览器实开待后端会话恢复后补核（六卡静态核对已通过）",
 "details/rice-accounting.html 浏览器实开待后端会话恢复后补核（六卡静态核对已通过）",
 "details/rice-energy-economics.html 浏览器实开待后端会话恢复后补核（六卡静态核对已通过）",
 "details/rice-finance.html 浏览器实开待后端会话恢复后补核（六卡静态核对已通过）",
 "details/wustl-sever-cybersecurity-management-ms.html 浏览器实开待后端会话恢复后补核（六卡静态核对已通过）",
]
b["pending_browser_check"]=[x for x in b.get("pending_browser_check",[]) if os.path.basename(x.split()[0]) not in [os.path.basename(p.split()[0]) for p in new_pending]]
b["pending_browser_check"]+=new_pending

bn=b.get("blocked_notes",[])
bn=[x for x in bn if not x.startswith("UT Stat") and not x.startswith("UT Math")]
bn.append("UT Statistics MSc / UT Mathematics MSc：系站返回 ~3.8–3.9KB 小字节拦截页（非项目正文），Cloudflare 类 challenge，仍不可读，保留卡点 #101，不凑数入库。")
bn.append("JHU engineering.jhu.edu / bme.jhu.edu 403；NYU gsas.nyu.edu 202 0B 空壳；Rice stat.rice.edu / jonesbusiness.rice.edu DNS 不通；UVA grad 站 202 0B；Emory CS SSL 错误；Duke Medical Physics 读取超时。")
bn.append("【本轮解除】Stanford cs.stanford.edu / gradadmissions.stanford.edu 由 403 恢复 200 真实正文（CS 系站 119KB / 招生站 40KB）；USC Viterbi 200 208935B、Rice CS 200 60422B 可达。Stanford todo 剩余条目全为 PhD（批次5），恢复留待批次5核验。")
b["blocked_notes"]=bn

eq=b.get("excluded_qual",[])
def add_eq(txt):
    if txt not in eq: eq.append(txt)
add_eq("MIT Sloan Master of Science in Management Studies (MSMS)：招生资格仅限合作/附属商学院（Asia School of Business、EDHEC、ESCP、ESSEC、复旦 IMBA、HEC Montréal、HEC Paris、HKU、IE、Imperial、INSEAD、McGill Desautels、SNU、SKKU、Tel Aviv Coller、Tsinghua Global MBA 等）的毕业生或在读生，属定向第二硕士/双联通道，非对普通申请者开放的终端硕士；按边界口径排除，不升级六卡、不入库 PROGRAMS，保留目录层待终检复核。")
b["excluded_qual"]=eq

b["note"]="第二十六轮：5 条硕士核验升级入库（MIT SCM Residential MEng · STEM；Rice MAcc；Rice MEEcon；Rice MFin；WUSTL Cybersecurity Management Sever）。官网未公布的截止/语言/标化/打包学费留空待补，不臆造；STEM 仅官网明示才标 1。批次4 升级 / 批次5 博士补齐与终检未完成。"
json.dump(b,open("_heartbeat_baseline.json","w",encoding="utf-8"),ensure_ascii=False,indent=2)
print("programs",b["programs"],"master",b["programs_master"],"phd",b["programs_phd"],"vd",b["vd_set"],"details",b["details_html"],"pending",len(b["pending_browser_check"]),"blocked",len(b["blocked_notes"]),"eq",len(b["excluded_qual"]),"mtime",mt)
