Feed Fetcher: A plugin for finding RSS feeds from URLs
Posted by Craig Ambrose on March 27, 2007 at 08:52 AM
I’ve got a site with a few blog aggregation features, and when users type in their blog URL to add to the site, they don’t seem to know the difference between the blog html page URL and the blog RSS feed URL.
So, I wanted the site to work regardless of which one they used, by finding RSS resource links from the HTML page (if that’s what they enter). This is what Google Reader and all the other nice looking blog readers do.
It’s not earth shatteringly exciting code, but it’s good enough to re-use, and it’s fully tested, so I’ve made into a plugin. Now there’s no excuse for offering a sloppy user experience for subscribing to feeds.
Installation
script/plugin install svn://rubyforge.org/var/svn/ambroseplugins/feed_fetcher
Usage
The main function that you’ll be using is the class method get_feed_source on the FeedFetcher class.
If successful, it’ll return a FeedSource object, that you can interrogate for the feed details or
the items in the current feed. If it fails, it’ll throw an exception that you can use to determine
the problem and return a message to the user.
Here’s the code that I use to call the feed fetcher from within my Blog model. If it works, I’m
setting a couple of instance members on self.
begin
result = FeedFetcher::FeedFetcher.get_feed_source(site_url)
if result
self.feed_url = result.url
self.title = result.title
end
rescue FeedFetcher::NoFeedForPageError
@feed_error = "Sorry, we couldn't find a feed for this URL. Your blog needs to have a RSS feed facility for us to use it on Playful Bent."
rescue FeedFetcher::PageFeedError
@feed_error = "You blog has a RSS feed, which is great. However, it doesn't work for us right now, which is less great. Sorry, this wont work."
rescue FeedFetcher::PageDoesntExistError
@feed_error = "Are you sure you typed that right? We just tried to fetch that URL and we couldn't find anything there at all."
end
More Info
I keep a static page on this plugin here. You can check back there for the current information at any point.

Comments
There are 4 comments on this post. Post yours →
When is this code going to be released?
It is released. Are you having any trouble accessing the repository?
i’m having problem installing it from repository via Aptana IDE.
Do you know some wordpress plugin work like this one ?
Post a comment
Required fields in bold.