From 977b01112e29c0c7eefcb7a33701c75aaf508128 Mon Sep 17 00:00:00 2001 From: Navan Chauhan Date: Fri, 13 Nov 2020 00:40:18 +0530 Subject: [PATCH] added try-except --- main.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 6b444d5..01dcef6 100644 --- a/main.py +++ b/main.py @@ -29,6 +29,7 @@ update_archive = True ############# def GetPosts(feed): + errored = False Posts = {} ToIgnore = [] ReadSummary = True @@ -57,7 +58,15 @@ def GetPosts(feed): except KeyError: None - rss = feedparser.parse(URL) + try: + rss = feedparser.parse(URL) + except: + print("Could not fetch data for feed: %s" % feed) + errored = True + + if errored: + return None + maximum = len(rss.entries) count = 0 @@ -171,7 +180,10 @@ for config in feed_configuration: posts = {} for feed in rss_feeds: sauce = GetPosts(feed) - posts[feed] = sauce + if sauce == None: + rss_feeds.remove(feed) + else: + posts[feed] = sauce #print(posts)