From 0820e5d90a3ffd49dac58333d236d4b889bc865b Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 15 Apr 2009 17:14:04 -0700 Subject: [PATCH] Implement #2277 (Remove empty feeds when fetching news with recipes) --- src/calibre/web/feeds/news.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/calibre/web/feeds/news.py b/src/calibre/web/feeds/news.py index a3642b0a33..2494951ccd 100644 --- a/src/calibre/web/feeds/news.py +++ b/src/calibre/web/feeds/news.py @@ -127,6 +127,12 @@ class BasicNewsRecipe(object, LoggingInterface): #: extra_css = None + #: If True empty feeds are removed from the output. + #: This option has no effect if parse_index is overriden in + #: the sub class. It is meant only for recipes that return a list + #: of feeds using :member:`feeds` or :method:`get_feeds`. + remove_empty_feeds = False + #: List of regular expressions that determines which links to follow #: If empty, it is ignored. For example:: #: @@ -994,6 +1000,11 @@ class BasicNewsRecipe(object, LoggingInterface): self.log_exception(msg) + remove = [f for f in parsed_feeds if len(f) == 0 and + self.remove_empty_feeds] + for f in remove: + parsed_feeds.remove(f) + return parsed_feeds @classmethod