From 7e006074808e3c233ae4cbe8abfa6d4fe228d085 Mon Sep 17 00:00:00 2001 From: Holger Schurig Date: Wed, 23 Jun 2010 11:14:30 +0200 Subject: [PATCH] rss_feed.py: sort items by modification time --- plugins/rss_feed.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/rss_feed.py b/plugins/rss_feed.py index a8adbec..1dbc11e 100644 --- a/plugins/rss_feed.py +++ b/plugins/rss_feed.py @@ -52,13 +52,20 @@ def sitemap_scan(params): link = full_url, guid = PyRSS2Gen.Guid("%s %s" % (full_url, file["mtime"]), isPermaLink=0), description = change, - pubDate = datetime.datetime.fromtimestamp(file["mtime"], utc), + pubDate = file["mtime"] ) items.append(item) @set_hook("finish") def finish(params): + # Sort items by pubDate, which still holds the mtime + items.sort(key=lambda i: i.pubDate, reverse=True) + + # convert mtime to real pupDate + for i in items: + i.pubDate = datetime.datetime.fromtimestamp(i.pubDate, utc) + rss = PyRSS2Gen.RSS2( title = cfg.subtitle, link = "http://%s" % cfg.main_url, -- 2.39.2