import re, os
base = os.path.dirname(os.path.abspath(__file__))
html = open(os.path.join(base, "index_main.html"), encoding="utf-8").read()
seg = re.search(r"const PROGRAMS\s*=\s*\[(.*?)\];", html, re.S).group(1)
blocks = re.findall(r"\{id:\"([^\"]+)\"([\s\S]*?)(?=\{id:\"|$)", seg)
bmap = {bid: body for bid, body in blocks}
vd = set(re.findall(r'"(details/[^"]+\.html)"', re.search(r"const VERIFIED_DETAILS[^;]+;", html).group(0)))
catd = re.search(r"const CATD\s*=\s*\[(.*?)\];", html, re.S).group(1)

for bid in ["uva-msacc", "uva-msa"]:
    body = bmap[bid]
    print("=" * 70)
    print(bid)
    print(body.strip()[:600])
    url = re.search(r'url:"([^"]*)"', body).group(1)
    print("url:", url, "| vd:", url in vd, "| catd:", f'"{url}"' in catd, "| disk:", os.path.exists(os.path.join(base, url)))
