# -*- coding: utf-8 -*-
import json, re, sys, io
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", errors="replace")
P = r"D:\work buddy\2026-11-05-14-15-52\index_main.html"
t = open(P, encoding="utf-8").read()
seg = t[t.index("const PROGRAMS=["):t.index("const CATD=[")]
blocks = re.split(r'(?=\{id:")', seg)[1:]
def get(b, k):
    m = re.search(k + r':"((?:[^"\\]|\\.)*)"', b)
    return m.group(1) if m else ""
meta = {get(b, "id"): {"disc": get(b, "disc"), "url": get(b, "url"), "ddl": get(b, "ddl"), "deg": get(b, "deg")} for b in blocks}
d = json.load(open(r"D:\work buddy\2026-11-05-14-15-52\_density_report.json", encoding="utf-8"))
hot = ["cs", "ee", "fin", "econ", "ba", "ds", "stat", "mech", "bio", "mgmt"]
for r in d["rows"]:
    if r["grade"] == "A" or r["s"] != "nyu":
        continue
    if meta.get(r["id"], {}).get("disc") not in hot:
        continue
    m = r["m"]
    print(f"{r['score']} {meta[r['id']]['disc']:5s} {r['id']:30s} ch{m['chars']} cd{m['codes']} mo{m['money']} dt{m['dates']} ext{m['ext_links']} c{m['cards']} | {r['n'][:26]} | {meta[r['id']]['url']}")
