read whole year

This commit is contained in:
2019-05-01 21:41:48 +02:00
parent 5ae10b7648
commit 7c662bdf64
2 changed files with 9 additions and 4 deletions

View File

@@ -298,9 +298,8 @@ class Infomentor(object):
url = 'News/NewsImage/GetImage?id={}'.format(id)
return self.download_file(url, directory='images', filename=filename)
def get_calendar(self, offset=0, weeks=1):
def get_calendar(self):
self.logger.info('fetching calendar')
data = self._get_week_dates(offset=offset, weeks=weeks)
data = {
'UTCOffset': utcoffset,
}

View File

@@ -228,7 +228,7 @@ class Informer(object):
cal = icx.get_named_calendar(cname)
if not cal:
cal = icx.create_calendar(cname)
calentries = self.im.get_calendar(weeks=4)
calentries = self.im.get_calendar()
known_entries = {}
for calevent in cal.events():
if calevent.data is None:
@@ -238,6 +238,7 @@ class Informer(object):
for entry in calentries:
self.logger.debug(entry)
uid = 'infomentor_{}'.format(entry['id'])
event_details = self.im.get_event(entry['id'])
self.logger.debug(event_details)
calend = Calendar()
@@ -247,7 +248,12 @@ class Informer(object):
event.add('description', event_details['notes'])
event.add('dtstart', dateparser.parse(entry['start']))
event.add('dtend', dateparser.parse(entry['end']))
self.logger.debug(event.to_ical())
calend.add_component(event)
new_cal_entry = calend.to_ical().decode('utf-8').replace('\r','')
if uid in known_entries:
if known_entries[uid].data == new_cal_entry:
self.logger.info('no change for calendar entry {}'.format(uid))
continue
self.logger.debug(calend.to_ical())
cal.add_event(calend.to_ical())