Combine multiple feeds with RSSBus

Here's an RSSBus script that will create an RSS feed that is a combination of two feeds:

<rsb:call op="http://api.flickr.com/services/feeds/groups_pool.gne?id=27144182@N00&format=rss_200">
    <rsb:push title="Flickr Gnarley Trees: [title]" />
</rsb:call>
<rsb:call op="http://api.flickr.com/services/feeds/groups_pool.gne?id=13378274@N00&format=rss_200">
    <rsb:push title="Flickr Flowers: [title]" />
</rsb:call>

In this example I don't just combine the feeds, but I have altered the title of each item to indicate which source feed it came from. All I do in this script is call the first feed, and prepend "Trees: " to the title for each item before I push it out. Then I call the 2nd feed, and prepend the text "Flowers: " to the title of each item before I push it out.

Note that the resulting feed contains all the items from the Flickr gnarley trees group as well as all the items from the Flickr flowers group. Also the resulting feed contains ALL elements of each item, not just the standard rss elements (in this example, that means the yahoo media information is present for each item).

If you're not familiar with RSSBus scripts, which produce feeds, just take a look at this 3 minute screencast. About 2/5 of the way through, the script editor is shown, where you can create a new script, paste the script above in, and voila you have a feed.

Filtering

I can also filter this feed in many ways, such as by date.  Here is an example of the above feed where it only shows items from the last 24 hours.  The differences:

  • I define an attribute called date.now, and set it to todays date/time
  • Instead of pushing every item with the prepended title, I check the difference in the publish date of each item and todays date.  If the difference is less than 1 day, only then do I push the item.

 

<rsb:set attr="date.now" value="[null | date()]" /> <rsb:call op="http://api.flickr.com/services/feeds/groups_pool.gne?id=27144182@N00&format=rss_200">   <rsb:set attr="datediff" value="[rss:pubDate | datediff('Day','[date.now]')]" />   <rsb:equals attr="datediff" value="0">     <rsb:push title="Trees: [title]" />   </rsb:equals> </rsb:call> <rsb:call op="http://api.flickr.com/services/feeds/groups_pool.gne?id=13378274@N00&format=rss_200">   <rsb:set attr="datediff" value="[rss:pubDate | datediff('Day','[date.now]')]" />   <rsb:equals attr="datediff" value="0">     <rsb:push title="Flowers: [title]" />   </rsb:equals> </rsb:call>

Technorati :

Print | posted on Wednesday, February 21, 2007 1:28 PM

Feedback

# re: Combine two feeds with RSSBus

Left by Technology Hacker at 4/30/2008 4:57 AM
Gravatar Thnaks a ton :)

Your comment:





 
 

Copyright © Lance Robinson

Design by Bartosz Brzezinski

Design by Phil Haack Based On A Design By Bartosz Brzezinski