# -*- coding: utf-8 -*-
import io, sys, json, os, datetime
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
p = "_heartbeat_baseline.json"
b = json.load(open(p, encoding="utf-8"))

DET = "details/cornell-c8dae13.html"
mt = os.path.getmtime("index_main.html")
MTIME = datetime.datetime.fromtimestamp(mt).strftime("%Y-%m-%d %H:%M:%S")

b["updated_at"] = MTIME
b["index_main_mtime"] = MTIME
b["schools"] = 36
b["programs"] = 212
b["programs_master"] = 211
b["programs_phd"] = 1
b["catd"] = 2676
b["dead_links"] = 0
b["excluded_residue"] = 0
b["vd_set"] = 276
b["details_html"] = 2864
b["node_check"] = "exit 0"

pend = DET + " 浏览器实开待后端会话恢复后补核（六卡静态核对已通过）"
if not any(DET in x for x in b["pending_browser_check"]):
    b["pending_browser_check"].append(pend)

bn = ("Cornell MEM MEng（cornell-mem-meng）：已核验入库。Duffield 工程学院 Engineering Management Program（隶属土木与环境工程系），"
      "Ithaca 在校全日制职业型 MEng，coursework + project-oriented；两学期最少 32 学分（major/supporting 课程 + Capstone + 两门研讨课），"
      "可选三学期 42 学分；七个既定 track 或自建方向（名称官网未完整列示）；Capstone ENMGT 5910 最后学期 2–7 人业界团队，"
      "PEP 冬季实习无薪独立研究学分、不保证分配；普通申请人仅秋季入学、截止 2 月 1 日，春季无对外通道，Early Admit 仅 Cornell 本科生；"
      "GRE 不要求，部分申请人可能面试；先修 Calculus 1/2/3、微分方程、一门概率统计、Technical Writing；"
      "GPA 资格线累计 ≥2.70/4.0、近三学期每门 ≥2.50（资格门槛，非录取分布）；语言 TOEFL iBT 新制口语/阅读 ≥4.5（旧 23/22）、听力/写作 ≥5.0（旧 22/24），"
      "代码 2098，或 IELTS Academic ≥7.0；申请费 $105，3 推荐信 + 简历 Required + 技术写作样本（≤5,000 词）+ 陈述材料 + 非官方成绩单；"
      "学费 Tier 1 Master's 费率 Bursar 年度更新，项目级费率/总额未单列留空；自费无 RA/TA，Engineering Management Fellowships 择优部分学费奖学金、录取一并评审；"
      "通用 FAQ 明示持 MEng 符合 STEM-OPT，stem:1；毕业 3 个月内 97% 学生获全职机会；班级规模/录取率/平均薪资/完整雇主名单未公布留空。")
if not any("cornell-mem-meng" in x for x in b["blocked_notes"]):
    b["blocked_notes"].append(bn)

eq = ("Cornell MEM MEng：不含 MEM Distance Learning 在线/在职版（国际生须人在美国境内参加 DL）；不含仅面向 Cornell 本科生的 Early Admit 贯通通道；"
      "不含研究型 M.S. 与 Ph.D. 独立通道；M.Eng. 为 terminal degree，在读不能转 PhD，须重新正式申请；与 Johnson 商学院仅为跨校区资源合作（Immersion Program），"
      "不含 Johnson MBA 或 MBA 双学位；七个 track 完整名称官网未列示，不臆造。")
if not any("cornell-c8dae13" in x for x in b["excluded_qual"]):
    b["excluded_qual"].append(eq)

note_add = (" 2026-11-18 再入库：Cornell Engineering Management MEng 在校 Ithaca 版 "
            "（details/cornell-c8dae13.html，在校全日制职业型，两学期 32 / 三学期 42 学分，STEM-OPT 可申）。")
if "cornell-c8dae13.html" not in b.get("note", ""):
    b["note"] = b.get("note", "") + note_add

json.dump(b, open(p, "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"], "mtime", MTIME,
      "pending", len(b["pending_browser_check"]), "blocked", len(b["blocked_notes"]),
      "excluded", len(b["excluded_qual"]))
