From 85c5c963928b355b1684eb59cf1c969eb3eee5b1 Mon Sep 17 00:00:00 2001 From: Corban-Lee Date: Tue, 10 Sep 2024 10:49:22 +0100 Subject: [PATCH] fix TypeError with empty title, desc, pub_date rssItems --- src/feed.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/feed.py b/src/feed.py index 443e86d..d077ff5 100644 --- a/src/feed.py +++ b/src/feed.py @@ -51,13 +51,13 @@ class RSSItem: RSSItem """ - guid = entry.get('id', None) or entry.get("guid", None) - link = entry.get('link', None) - title = entry.get('title', None) - description = entry.get('description', None) + guid = entry.get('id', None) or entry.get("guid") + link = entry.get('link', "") + title = entry.get('title', "") + description = entry.get('description', "") pub_date = entry.get('published_parsed', None) - pub_date = datetime(*pub_date[0:6], tzinfo=timezone.utc) + pub_date = datetime(*pub_date[0:6] if pub_date else None, tzinfo=timezone.utc) content_image_url = entry.get("media_content", [{}])[0].get("url") thumb_image_url = entry.get("media_thumbnail", [{}])[0].get("url") @@ -128,6 +128,8 @@ class RSSItem: discord.Embed """ + log.debug("Creating embed of item: %s", self.guid) + # Replace HTML with Markdown, and shorten text. title = shorten(markdownify(self.title, strip=["img", "a"]), 256) desc = shorten(markdownify(self.description, strip=["img"]), 4096)