Fix #47.
All checks were successful
continuous-integration/drone Build is passing

This commit is contained in:
Alexey Skobkin 2023-06-25 19:37:52 +03:00
parent 31c112a4fa
commit 08b2d216ee
No known key found for this signature in database
GPG key ID: 5D5CEF6F221278E7
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.title = item.get('title', '')
self.description = item.get('summary', '') self.description = item.get('summary', '')
self.guid = item.get('id', '') 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)) self.date = datetime.fromtimestamp(mktime(item.published_parsed))
else: else:
self.date = None self.date = None

View file

@ -163,9 +163,13 @@ class Notifier:
self.sent_counter += 1 self.sent_counter += 1
def __format_message(self, item: FeedItem) -> str: 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 ( return (
f"<strong><a href=\"{item.url}\">{item.title}</a></strong>\n" 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)}" f"{self.__sanitize_html(item.description)}"
) )