summaryrefslogtreecommitdiff
path: root/rem2ics
diff options
context:
space:
mode:
authorAnton Bobov <abobov@gmail.com>2021-04-21 22:21:30 +0500
committerAnton Bobov <abobov@gmail.com>2021-04-21 22:21:30 +0500
commit9b340bc745a39699b0ee66c2521b81d2499407ce (patch)
treef44c3653473f762027fd428ec81363d87bc23052 /rem2ics
parenta451afe3f0089eac899d3885c6caeebe8ea5de79 (diff)
Updates.
Diffstat (limited to 'rem2ics')
-rwxr-xr-xrem2ics28
1 files changed, 23 insertions, 5 deletions
diff --git a/rem2ics b/rem2ics
index 0694ff4..33b4f2b 100755
--- a/rem2ics
+++ b/rem2ics
@@ -26,11 +26,21 @@ class Event:
def summary(self):
e = self.event_json
- summary = e.get('body', '').replace(r'%"', '')
- if 'time' in e:
- summary = summary.split(' ', 1)[1]
- if 'passthru' in e and 'COLOR' in e['passthru']:
- summary = ' '.join(summary.split(' ')[3:])
+ summary = e.get('body', '')
+ match = re.search(r'%"(.+)%"', summary)
+ if match:
+ summary = match.group(1)
+ else:
+ summary = self.__remove_spec(e, summary)
+ return escape_text(summary)
+
+ def description(self):
+ e = self.event_json
+ summary = e.get('body', '')
+ if '%"' not in summary:
+ return ""
+ summary = summary.replace(r'%"', '')
+ summary = self.__remove_spec(e, summary)
return escape_text(summary)
def categories(self):
@@ -58,6 +68,13 @@ class Event:
def __datetime_format(dt):
return dt.astimezone(timezone.utc).strftime('%Y%m%dT%H%M%SZ')
+ def __remove_spec(self, event, summary):
+ if 'time' in event:
+ summary = summary.split(' ', 1)[1]
+ if 'passthru' in event and 'COLOR' in event['passthru']:
+ summary = ' '.join(summary.split(' ')[3:])
+ return summary
+
def create_uid(event):
if 'rep' in event and 'until' in event:
@@ -76,6 +93,7 @@ def print_ics(events):
print('DTSTART:%s' % event.dtstart())
print('DTEND:%s' % event.dtend())
print('SUMMARY:%s' % event.summary())
+ print('DESCRIPTION:%s' % event.description())
print('CATEGORIES:%s' % event.categories())
print('END:VEVENT')
print('END:VCALENDAR')