Fixing notification error when date is None. #48
4
rss.py
4
rss.py
|
@ -10,7 +10,9 @@ class FeedItem:
|
|||
self.title = item.get('title', '')
|
||||
self.description = item.get('summary', '')
|
||||
self.guid = item.get('id', '')
|
||||
if 'published' in item:
|
||||
if 'updated' in item:
|
||||
self.date = datetime.fromtimestamp(mktime(item.updated_parsed))
|
||||
elif 'published' in item:
|
||||
self.date = datetime.fromtimestamp(mktime(item.published_parsed))
|
||||
else:
|
||||
self.date = None
|
||||
|
|
|
@ -163,9 +163,13 @@ class Notifier:
|
|||
self.sent_counter += 1
|
||||
|
||||
def __format_message(self, item: FeedItem) -> str:
|
||||
date_string = ''
|
||||
if item.date is not None:
|
||||
date_string = item.date.strftime('%m.%d.%Y %H:%M')
|
||||
|
||||
return (
|
||||
f"<strong><a href=\"{item.url}\">{item.title}</a></strong>\n"
|
||||
f"{item.date.strftime('%m.%d.%Y %H:%M')}\n\n"
|
||||
f"{date_string}\n\n"
|
||||
f"{self.__sanitize_html(item.description)}"
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue