# -*- coding: utf-8 -*-
import io, re, collections
t = io.open('index_main.html', encoding='utf-8').read()
seg = re.search(r'PROGRAMS\s*=\s*\[(.*?)\n\s*\];', t, re.S).group(1)
c = collections.Counter()
odd = []
for i in re.finditer(r'\{id:"([^"]+)"', seg):
    pid = i.group(1)
    nxt = seg.find('{id:"', i.start() + 6)
    blk = seg[i.start():nxt if nxt > 0 else len(seg)]
    m = re.search(r'lvl:"([^"]*)"', blk)
    c[m.group(1) if m else 'none'] += 1
    if m and m.group(1) not in ('d', 'm'):
        odd.append((pid, m.group(1)))
print(c, len(odd), odd[:5])
