View Single Post
Old 01-19-2010, 02:05 PM   #3
BrianG began at the beginning.
Posts: 23
Karma: 22
Join Date: Dec 2009
Device: Kindle DX
Add FEED objects during PARSE_INDEX

There is a slight difference between the Feeds object that is returned from PARSE_FEEDS and the object returned when using PARSE_INDEX.

The module below (FEED_TO_INDEX_APPEND) accepts a Feed object and an Index object. The Feed object is traversed and appended to the Index.

This can be useful in mixing the use of an index as well as RSS feeds in a single recipe. It could be called in a way similar to:

	# Do the "official" parse_feeds first
	rssFeeds = Feed()
	rssFeeds = BasicNewsRecipe.parse_feeds(self)

	# Append the rssFeeds object to the feeds list that would be
             # used in PARSE_INDEX
	self.feed_to_index_append(rssFeeds[:], feeds)

Here is the conversion module:

   def feed_to_index_append(self, feedObject, masterFeed):

	# Loop thru the feed object and build the correct type of article list
	for feed in feedObject:
		newArticles = []
		for article in feed.articles:
			newArt = {
	                          'title' : article.title,
      	                          'url'   : article.url,
            	                          'date'  :,
                  	              'description' : article.text_summary

		# append the newly-built list object to the index object 		             # passed in as masterFeed.

Last edited by Starson17; 02-25-2011 at 10:07 PM.
BrianG is offline   Reply With Quote