diff --git a/parser.py b/parser.py index bfd656d..cf2ef5c 100755 --- a/parser.py +++ b/parser.py @@ -45,6 +45,8 @@ class GoogleSheetsCalParser(HTMLParser): self.rowspan = 0 self.multirows = {} self.date = {} + self.event = Event() + self.event['uid'] = 0 import priv @@ -106,16 +108,19 @@ class GoogleSheetsCalParser(HTMLParser): cal = Calendar() cal.add('prodid', '-//edpibu//edt-parser//FR') cal.add('version', '2.0') - event = Event() - event.add('uid', f'{self.row}x{self.column}') - event.add('summary', data) - event.add('dtstamp', dt.now()) - print(self.row, self.column, times) - event.add('dtstart', dt.combine(self.date[self.column], times[0], - pytz.timezone('Europe/Paris'))) - event.add('dtend', dt.combine(self.date[self.column], times[1], - pytz.timezone('Europe/Paris'))) - cal.add_component(event) + if self.event['uid'] == f'{self.row}x{self.column}': + self.event['summary'] = f'{self.event["summary"]} {data}' + else: + self.event = Event() + self.event.add('uid', f'{self.row}x{self.column}') + self.event.add('summary', data) + self.event.add('dtstamp', dt.now()) + print(self.row, self.column, times) + self.event.add('dtstart', dt.combine(self.date[self.column], times[0], + pytz.timezone('Europe/Paris'))) + self.event.add('dtend', dt.combine(self.date[self.column], times[1], + pytz.timezone('Europe/Paris'))) + cal.add_component(self.event) self.calendar.save_event(cal.to_ical().decode('utf-8'))