~bronikowski/elevencal

da8d74152eee65cd77ad7442ba028c70e603cd57 — Emil Oppeln-Bronikowski 8 months ago 9014f9d
Make a big-ass calendar
1 files changed, 12 insertions(+), 0 deletions(-)

M polsat.py
M polsat.py => polsat.py +12 -0
@@ 33,10 33,22 @@ def populate_calendar(calendar: Calendar, program):
        calendar.add_component(event)
    return calendar

big_ass_calendar = []
for c in data['channels']:
    if  c['title'] not in polsat_options.keys():
        continue
    calendar = prepare_calendar(c['title'])
    calendar = populate_calendar(calendar, c['programs'])
    big_ass_calendar.append(calendar)
    with open('{}.ics'.format(polsat_options[c['title']]), 'wb') as f:
        f.write(calendar.to_ical())

if big_ass_calendar:
    calendar = prepare_calendar('Polsat')
    for c in big_ass_calendar:
        for s in c.subcomponents:
            description = c['summary'] + ': ' + str(s.pop('description'))
            s.add('description', description)
            calendar.add_component(s)
    with open('polsat.ics', 'wb') as f:
        f.write(calendar.to_ical())