~bronikowski/elevencal

f22f6209b34fd29b8b85aaee9dea716f8efd1396 — Emil Oppeln-Bronikowski 5 months ago da8d741
TZ info included
1 files changed, 4 insertions(+), 2 deletions(-)

M polsat.py
M polsat.py => polsat.py +4 -2
@@ 6,6 6,7 @@ from datetime import datetime, date
from pprint import pprint
from const import polsat_options, POLSAT_URL
from icalendar import Event, Calendar
import pytz

data = requests.get(POLSAT_URL.format(date.today), headers={'User-agent': 'Mozilla/5.0'})
data.encoding = 'utf-8'


@@ 20,12 21,13 @@ def prepare_calendar(title) -> Calendar:
    return calendar

def populate_calendar(calendar: Calendar, program):
    tzinfo = pytz.timezone('Europe/Warsaw')
    for a in program:
        if not a['live']:
            continue
        event = Event()
        event.add('dtstart', datetime.fromtimestamp(a['emissionDate']/1000))
        event.add('dtend', datetime.fromtimestamp( (a['emissionDate']/1000) + 3659 ) )
        event.add('dtstart', datetime.fromtimestamp(a['emissionDate']/1000, tzinfo))
        event.add('dtend', datetime.fromtimestamp( (a['emissionDate']/1000) + 3659, tzinfo) )
        event.add('dtstamp', datetime.now())
        event.add('description', a['preview'])
        event.add('summary', a['title'])