From 509ed07cacbbd56ade07db72f21915920760fc02 Mon Sep 17 00:00:00 2001 From: Holger Schurig Date: Wed, 23 Jun 2010 11:27:03 +0200 Subject: [PATCH] rss_feed.py: limit number of published items via "rss_max_items" --- plugins/rss_feed.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/rss_feed.py b/plugins/rss_feed.py index 6810e94..580d304 100644 --- a/plugins/rss_feed.py +++ b/plugins/rss_feed.py @@ -16,6 +16,8 @@ def checkconfig(params): if not cfg.has_key("rss_file"): log('no "rss_file:" configured, using "feed.rss":', 4) cfg.rss_file = "feed.rss" + if not cfg.has_key("rss_max_items"): + cfg.rss_max_items = 0 if cfg.has_key("rss_max_age_days"): import time global max_age @@ -66,9 +68,15 @@ def sitemap_scan(params): @set_hook("finish") def finish(params): + global items # Sort items by pubDate, which still holds the mtime items.sort(key=lambda i: i.pubDate, reverse=True) + # Limit to requested number + count = int(cfg.rss_max_items) + if count: + items = items[:count] + # convert mtime to real pupDate for i in items: i.pubDate = datetime.datetime.fromtimestamp(i.pubDate, utc) -- 2.39.2