I finally got around to trying Yahoo! Pipes. What this is, primarily, is a visual programming language for operating on RSS feeds. It also handles some other data formats, but that’s the essence of it.
While it seemed cool when I first heard of it, I only recently had something which made it useful to me. I upgraded the Squeezecenter software for my Squeezebox (wireless ethernet music player), and it broke my favorite third-party module, SuperDateTime. I use SuperDateTime to replace the builtin clock functionality with one which shows the weather.
While I could just fix SuperDateTime (or wait for the maintainer to fix it), I noticed that the Squeezebox has a very simple RSS reader. This led me to googing for RSS feeds of weather and configuring it to display one. I happened to opt for Yahoo’s, because it’s well documented. But, this kind of sucked — The verbose form of the weather report and forecast was so much text that you could stare at the the squeezebox for half a minute while it scrolled all the text by.
Here’s where the Pipes comes in. I decided, why not minimize the feed to only the essential information. Basically, a simple task is required:
- Fetch the weather RSS for the appropriate location.
- Extract the current temperature and condition (Sunny, Cloudy, etc.)
- Extract the temperature and condition from the nearest (in time) forecast.
- Build a string out of this, one line of text.
- Spit out a feed where there is one item, where the title is the location and the description is this string.
But, while Pipes makes some things so easy (parsing XML, for example), it makes other things relatively hard or clumsy, at least to someone who is familiar with (text) programming languages. It was not without a learning curve.
Here is the result of my efforts. (Click view source if you want to follow along.)
What it does, in Pipes modules is:
- Get a zipcode and units (F or C) from the user who is instantiating it. (Might as well make it generic.)
- Convert the units to lowercase if they are not already (for the RSS feed syntax.)
- Convert the units to uppercase for display
- Fetch the corresponding weather feed.
- Loop over the items in the input, and for each, use the String Builder module (a lot more clumsy than a simple s(n)printf or string concatenation operator) to build up the output string, assigning this string to the description field of the item.
- Yet another loop to build a feed of new items, assigning the zipcode to the title of the item and the description to the description, eliminating the irrelevant data in the source feed.
Now, I suppose that wasn’t so bad. I know that my second use of Yahoo! Pipes will be much less troublesome than the first time I used it, but the lack of easy to use sprintf-like constructs and the need to use this explicit “loop over this feed and apply this module to every item in it” seemed a bit tiresome.
It does however provide a bit of inspiration for how one could create an easy to use (for the experienced python programmer) set of classes in python for doing this sort of processing of RSS feeds while abstracting away the low-level details. Also, I’m pleased to see an attempt at a visual programming language — something I think we see so little of, not for reasons involving the limitations of computers, but because of the power of plain text.