Merge pull request 'Fixing notification error when date is None.' (#48) from fix_47 into master
All checks were successful
continuous-integration/drone/push Build is passing

Reviewed-on: #48
Reviewed-by: Miroslavsckaya <miroslavsckaya@noreply.git.skobk.in>
This commit is contained in:
Miroslavsckaya 2023-06-26 15:58:25 +00:00
commit 20acceed8c
2 changed files with 8 additions and 2 deletions

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