# -*- 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="):])
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"]=2864
b["node_check"]="exit 0"

new_pending=[
 "details/up-c0e9103.html 浏览器实开待后端会话恢复后补核（六卡静态核对已通过）",
 "details/yale-statistics.html 浏览器实开待后端会话恢复后补核（六卡静态核对已通过）",
 "details/cmu-c2ee442.html 浏览器实开待后端会话恢复后补核（六卡静态核对已通过）",
 "details/mit-finance.html 浏览器实开待后端会话恢复后补核（六卡静态核对已通过）",
 "details/mit-business-analytics.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("Stanford cs.stanford.edu / gradadmissions.stanford.edu 403；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 读取超时。USC Viterbi 200 208935B、Rice CS 200 60519B 可达，留待下轮候选。")
b["blocked_notes"]=bn

eq=b.get("excluded_qual",[])
def add_eq(txt):
    if txt not in eq: eq.append(txt)
add_eq("Notre Dame Data Science MS（Professional）：Residency 为 Online，21 个月 part-time（6 学分/学期 × 5 学期），面向维持全职就业者，按线上/远程/在职口径排除，不升级六卡、不入库 PROGRAMS，保留目录层待终检复核。")
add_eq("WUSTL Statistics and Data Science MA（Statistics for Political Science PhD Students Concentration）：面向本校政治学 PhD 在读生的定制统计硕士，非对外招生终端硕士，按在校生贯通/PhD 通道口径排除，保留目录层待终检复核。")
b["excluded_qual"]=eq

b["note"]="第二十五轮：5 条硕士核验升级入库（UPenn DS&AI MSE / Yale Statistics MA / CMU MSCS 占位核验化 / MIT MFin / MIT MBAn）。官网未公布的截止/语言/GRE/打包学费留空待补，不臆造；STEM 仅官网明示才标 1，本轮均 stem:0。批次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"],"pending",len(b["pending_browser_check"]),"blocked",len(b["blocked_notes"]),"eq",len(b["excluded_qual"]),"mtime",mt)
