From 7d4d1311bb8fb96938ad2a15669a0dcf39071611 Mon Sep 17 00:00:00 2001 From: Denis Lehmann Date: Sun, 19 Apr 2020 16:04:22 +0200 Subject: [PATCH] show error message if no articles were returned from feedparser --- spiderss.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spiderss.py b/spiderss.py index 99ea317..45ba037 100755 --- a/spiderss.py +++ b/spiderss.py @@ -56,6 +56,7 @@ Utility functions # Get articles of a feed def get_articles(feed): + feed = feedparser.parse(feed['url']) return feed.entries @@ -216,6 +217,9 @@ def update_feed(feed): # Update articles articles = get_articles(feed) threshold_date = datetime.now() - timedelta(days = max_age) + + if len(articles) == 0: + error('no articles received from feed "{}"'.format(feed['name'])) for a in articles: @@ -302,7 +306,7 @@ def initialize(): os.makedirs(lovedpath) -# Update all feeds and delete old messages +# Update all feeds and remove old articles def crawl(): log('crawling feeds', True)