From 1dfd2d2b3c1031799275d7b8be7d5a3abe7e159e Mon Sep 17 00:00:00 2001 From: Matthew Hickson Date: Sat, 23 Nov 2024 22:16:44 -0500 Subject: [PATCH] fixed issue with podcast episode parsing resulting in errors re: NoneType --- tuipod/models/podcast.py | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/tuipod/models/podcast.py b/tuipod/models/podcast.py index 16d58a5..c56b044 100644 --- a/tuipod/models/podcast.py +++ b/tuipod/models/podcast.py @@ -35,21 +35,26 @@ def get_episode_list(self) -> []: for e in episodes.iter("item"): title = e.find("title").text - raw_description = e.find("description").text - soup = BeautifulSoup(raw_description, "html.parser") # I'd change "soup", but I like it... - clean_description = soup.get_text() - description = clean_description - enclosure = e.find("enclosure") - url = enclosure.attrib["url"] - - pubdate = e.find("pubDate").text - - duration = 0 - possible_duration = e.find("itunes:duration") - if not possible_duration is None: - duration = possible_duration.text - - self.episodes.append(Episode(title, url, description, pubdate, duration)) + if not enclosure is None: + url = enclosure.attrib["url"] + + raw_description = e.find("description").text + if not raw_description is None: + soup = BeautifulSoup(raw_description, "html.parser") # I'd change "soup", but I like it... + clean_description = soup.get_text() + description = clean_description + else: + description = "" + + pubdate = e.find("pubDate").text + + duration = 0 + possible_duration = e.find("itunes:duration") + if not possible_duration is None: + duration = possible_duration.text + + if not url is None: + self.episodes.append(Episode(title, url, description, pubdate, duration)) return self.episodes