From 3e609581cf0fb292f4c00f961d959f21a60a9cd8 Mon Sep 17 00:00:00 2001 From: boyska Date: Fri, 6 May 2022 13:28:08 +0200 Subject: [PATCH] podcast: ignores broken items --- larigira/audiogen_podcast.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/larigira/audiogen_podcast.py b/larigira/audiogen_podcast.py index a7c5d8d..8a54927 100644 --- a/larigira/audiogen_podcast.py +++ b/larigira/audiogen_podcast.py @@ -142,16 +142,21 @@ def get_audio_from_item(item): def get_urls(tree): items = tree.xpath("//item") - for it in items: - # title = it.find("title").text - audio = get_audio_from_item(it) + for i, it in enumerate(items): + try: + audio = get_audio_from_item(it) + except Exception: + logging.error("Could not parse item #%d, skipping", i) + continue if audio is None: continue if audio.date is None: - audio.date = get_item_date(it) + try: + audio.date = get_item_date(it) + except Exception: + logging.warn("Could not find date for item #%d", i) yield audio - def parse_duration(arg): if arg.isdecimal(): secs = int(arg)