Fixing notification error when date is None. #48

Merged
Miroslavsckaya merged 1 commit from fix_47 into master 2023-06-26 15:58:26 +00:00
2 changed files with 8 additions and 2 deletions
Showing only changes of commit 08b2d216ee - Show all commits

4
rss.py
View file

@ -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

View file

@ -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)}"
)