# -*- coding: utf-8 -*-
import io, re, sys
BASE = r"D:\work buddy\2026-11-05-14-15-52"
html = io.open(BASE + r"\index_main.html", encoding="utf-8").read()
seg = re.search(r"PROGRAMS\s*=\s*\[(.*?)\n\s*\];", html, re.S).group(1)
blocks = [b for b in re.split(r'(?=\bid:")', seg) if 'id:"' in b]


def get(b, k):
    m = re.search(r'\b%s\s*:\s*"([^"]*)"' % k, b)
    return m.group(1) if m else ""


ids = set(sys.argv[1:])
for b in blocks:
    i = get(b, "id")
    if not ids or i in ids:
        print("==" * 8, i)
        for k in ["s", "n", "en", "dept", "college", "disc", "lvl", "deg", "dur", "stem", "rank", "ddl", "lang", "tui", "url"]:
            print("  %-8s %s" % (k, get(b, k)))
        m = re.search(r'test\s*:\s*\{\s*cls\s*:\s*"([^"]*)"', b)
        print("  test     %s" % (m.group(1) if m else ""))
