fix TypeError with empty title, desc, pub_date rssItems
All checks were successful
Build and Push Docker Image / build (push) Successful in 8s
Build and Push Docker Image / build (pull_request) Successful in 8s

This commit is contained in:
Corban-Lee Jones 2024-09-10 10:49:22 +01:00
parent 1d78a05807
commit 85c5c96392

View File

@ -51,13 +51,13 @@ class RSSItem:
RSSItem RSSItem
""" """
guid = entry.get('id', None) or entry.get("guid", None) guid = entry.get('id', None) or entry.get("guid")
link = entry.get('link', None) link = entry.get('link', "")
title = entry.get('title', None) title = entry.get('title', "")
description = entry.get('description', None) description = entry.get('description', "")
pub_date = entry.get('published_parsed', None) 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") content_image_url = entry.get("media_content", [{}])[0].get("url")
thumb_image_url = entry.get("media_thumbnail", [{}])[0].get("url") thumb_image_url = entry.get("media_thumbnail", [{}])[0].get("url")
@ -128,6 +128,8 @@ class RSSItem:
discord.Embed discord.Embed
""" """
log.debug("Creating embed of item: %s", self.guid)
# Replace HTML with Markdown, and shorten text. # Replace HTML with Markdown, and shorten text.
title = shorten(markdownify(self.title, strip=["img", "a"]), 256) title = shorten(markdownify(self.title, strip=["img", "a"]), 256)
desc = shorten(markdownify(self.description, strip=["img"]), 4096) desc = shorten(markdownify(self.description, strip=["img"]), 4096)