Archive for Tubes

Tubes Beats Yahoo Pipes: Feed Fixup

Although it has only been a couple of weeks since I started work on Tubes, the mechanism I put in place to output feeds is already serving me very well. So well that it’s approaching all of my personal needs. This may potentially be bad for other people, but it’s great for me. Besides, I put the code out there; it should be easy enough to fork it if you wish it to do more! Bitbucket is also said to make it easy to merge such changes in later. I should also point out that the large majority of the work was of course done by the people who made SimplePie.

Anyway, I wanted to subscribe to the UN News podcast. To my surprise, gPodder was incapable of handling it. No surprise, as it turns out, because it’s not even proper according to the iTunes enclosure specification (although I imagine it works in iTunes). SimplePie had a nice get_enclosure() function already, so the first step, adding a proper enclosure to my Tube’s output feed, was a matter of minutes. The UN also fails to specify any size information, however, which I can’t say I was too enthused about in my trusty gPodder interface. Another 10 minutes or so later, I finished adding some cURL magic to my application. I should probably stash it away into a class later and see if I can somehow make it utilize SimplePie’s cache system to minimize useless traffic, but for now I just stuck it straight in the feed generation code. Now the UN feed is transformed from something gPodder couldn’t handle into something that essentially fixes all the UN did wrong. Thank you SimplePie for providing this great foundation!

Before (RSS):

<item>
  <title>UN Daily News 12 March 2010</title>
  <itunes:author>United Nations Radio</itunes:author>
  <itunes:subtitle>News and features from United Nations Radio.</itunes:subtitle>
  <itunes:summary></itunes:summary>
  <enclosure url="http://downloads.unmultimedia.org/radio/en/ltd/mp3/2010/10031200.mp3" length="" type="audio/mpeg" />
  <guid>http://downloads.unmultimedia.org/radio/en/ltd/mp3/2010/10031200.mp3</guid>
  <pubDate>Fri, 12 Mar 2010 11:42:32 EST</pubDate>
  <itunes:duration>0:00</itunes:duration>
</item>

After (Atom):

<entry>
  <author>
   <name>United Nations Radio</name>
  </author>
  <title>UN Daily News 12 March 2010</title>
  <summary> </summary>
  <published>2010-03-12T11:42:32-05:00</published>
  <updated>2010-03-12T11:42:32-05:00</updated>
  <id>http://downloads.unmultimedia.org/radio/en/ltd/mp3/2010/10031200.mp3</id>
  <link rel="enclosure" type="audio/mpeg" href="http://downloads.unmultimedia.org/radio/en/ltd/mp3/2010/10031200.mp3" length="6720384" />
  <link rel="alternate" type="text/html" href="http://downloads.unmultimedia.org/radio/en/ltd/mp3/2010/10031200.mp3"/>
</entry>

I realize the alternate link currently has the wrong type attribute, which I’ll look into fixing, but at least my gPodder can handle the feed now.

I also set up a little demo so you can check the difference with the original feed for yourselves. I’d be curious to hear how different podcatchers handle both feeds.

Comments

SimplePie-based Feed Mashup

This tool is now named Tubes and is hosted on Bitbucket.

As I wrote a few months ago, Yahoo Pipes is a nice tool. Nonetheless, it has a few shortcomings which annoyed me because I could neither fix nor work around them. Therefore, I decided to write my own mashup tool. For the impatient, you can download the file right now before reading anything else.

Since SimplePie seems to be the feed aggregation library of choice for many projects, I decided to go with it. I ran into a few minor issues, but nothing I couldn’t handle easily. The code I wrote is based on the multifeeds.php demo file and SimplePie 1.1.3, because in 1.2 it didn’t work (the multifeeds demo, that is — by extension I suppose this file won’t either). It’s a little rough around the edges, and SimplePie is clearly meant for HTML output rather than XML (although its HTML isn’t quite decent either, even if the input feed is), so I decided to fix the whole thing up with Tidy, which takes care of low quality input material as well. Hopefully that makes this whole thing more robust than it would otherwise be. The code is based around bringing various Opera feeds I read together in one big feed, but this can very easily be changed.

So now that I’ve got the basics of output into a feed taken care of, I can easily duplicate other functionality of Yahoo Pipes if I want. Much better.

Comments