diff --git a/planet/spider.py b/planet/spider.py index d9b4c00..b5cd2a0 100644 --- a/planet/spider.py +++ b/planet/spider.py @@ -187,11 +187,16 @@ def spiderFeed(feed): # capture feed and data from the planet configuration file if not data.feed.has_key('links'): data.feed['links'] = list() + feedtype = 'application/atom+xml' + if data.version.startswith('rss'): feedtype = 'application/rss+xml' + if data.version in ['rss090','rss10']: feedtype = 'application/rdf+xml' for link in data.feed.links: - if link.rel == 'self': break + if link.rel == 'self': + link['type'] = feedtype + break else: data.feed.links.append(feedparser.FeedParserDict( - {'rel':'self', 'type':'application/atom+xml', 'href':feed})) + {'rel':'self', 'type':feedtype, 'href':feed})) for name, value in config.feed_options(feed).items(): data.feed['planet_'+name] = value diff --git a/tests/test_spider.py b/tests/test_spider.py index aa0a6c1..01e730a 100644 --- a/tests/test_spider.py +++ b/tests/test_spider.py @@ -58,6 +58,8 @@ class SpiderTest(unittest.TestCase): # verify that the file timestamps match atom:updated data = feedparser.parse(files[2]) + self.assertEqual(['application/atom+xml'], [link.type + for link in data.entries[0].source.links if link.rel=='self']) self.assertEqual('one', data.entries[0].source.planet_name) self.assertEqual(os.stat(files[2]).st_mtime, calendar.timegm(data.entries[0].updated_parsed)) @@ -82,5 +84,7 @@ class SpiderTest(unittest.TestCase): data = feedparser.parse(workdir + '/planet.intertwingly.net,2006,testfeed3,1') + self.assertEqual(['application/rss+xml'], [link.type + for link in data.entries[0].source.links if link.rel=='self']) self.assertEqual('three', data.entries[0].source.author_detail.name)