July 16, 2010
Wordpress RSS and Planet

I’m using Planet for aggregating different blogs in a single website. OK, just in case you don’t know what’s a planet, it’s just that: a blog aggregator.

After adding a couple of blogs, I’ve found weird things with the feeds that Wordpress hosting service provides: even if you configure your blog to serve the full posts in the RSS, Wodpress is serving a summary in the description field.

Oh, they’re serving the full post too (as you configured), but they’re using content:encoded instead the description field.

In consequence, Planet is showing the 300 character long summary, instead of the expected full post.

That’s an old issue, and seems it won’t be fixed (well, you could argue that there’s nothing broken here; but I would then disagree).

So I’ve patched my Planet with a small hack to use the content instead of the description, and at the same time avoid a complaint from Planet for the format of the content:encoded.

--- a/planet/feedparser.py	2006-07-27 01:53:35.000000000 +0200
+++ b/planet/feedparser.py	2010-07-16 14:21:35.000000000 +0200
@@ -2695,7 +2695,12 @@
         feedparser = _LooseFeedParser(baseuri, baselang, known_encoding and 'utf-8' or '')
         feedparser.feed(data)
     result['feed'] = feedparser.feeddata
-    result['entries'] = feedparser.entries
+    entries = feedparser.entries
+    for e in entries:
+        if 'content' in e and e['content'][0]['type'] == 'text/html':
+            e['summary'] = e['content'][0]['value']
+            del e['content']
+    result['entries'] = entries
     result['version'] = result['version'] or feedparser.version
     result['namespaces'] = feedparser.namespacesInUse
     return result

It applies to 2.0 release of Planet, and feel free to use it at your own risk.

by jjm on 1:55pm  |   URL: http://tumblr.com/ZPorZymrSY6
(View comments
Filed under: planet wordpress rss hack python patch 
Blog comments powered by Disqus