Sunday, January 13

How to add a daily summary of Flickr photos to your blog’s feed

I’m a fan of FeedBurner, and I love their Link Splicer feature for adding each day’s new links to my feed. I wanted to do the same kind of thing for my photos.

FeedBurner supports Flickr for their Photo Splicer feature, but it splices in each image as an individual entry — far too spammy. Yahoo Pipes to the rescue!

Short version: Use my Flickr Daily Summary pipe to generate a feed with a post for your most recent day’s uploads. Then, create your own pipe and use the Union operator to merge the Flickr Daily Summary feed with your blog’s feed. You can use Blogger’s Post Feed Redirect URL setting to guide your subscribers to the new, unioned feed.

Update, 1/17: If you were trying this out and just got my photos from the 12th, try again. I just found that in refactoring I think some sub-Pipes flipped back to their default, debug settings. All is fixed now.

Long version about implementation and such:
From what I can tell, Yahoo Pipes doesn’t have a great way to merge several entries into one, so we can’t summarize based on the standard Flickr feed. Instead, we can use Pipes’ Fetch Page source to scrape Flickr’s daily archive page. The Get Day’s Flickr Thumbnails pipe does just this.

In order to load the correct daily archive page, however, we need to know what date to look for. The Flickr Daily Summary pipe does this by looking at the most recent entry in your Flickr feed.

There’s a bit of a caveat surrounding dates and timezones, however: Flickr’s <pubDate> elements are in US/Pacific, your photo archive is in your Flickr account’s timezone (US/Eastern in my case), and Pipes internally converts all dates to UTC. This last bit is significant because it affects the output of the Date Formatter module. When I first tried getting the daily archive page for the photos I uploaded at 11PM last night, Pipes was generating a date string for early this morning, UTC time: the wrong day. I wrote the Correct Timezone pipe to subtract the right number of hours from a date so that formatting it gave the output one would expect.

With the feed content in place, the last remaining step is to get the metadata right. The <author> element is just taken from the latest Flickr feed entry, as is the <pubDate>. The <link> and <guid> are both set to the daily archive page’s URL.

Important undocumented useful Pipes tips: To set the <pubDate> of an entry, you must set the y:published attribute to a date. To set the <guid> of an entry, you must set the y:id.value attribute.

Armed with a feed that will supply daily Flickr summaries (albeit one at a time, but that’s why aggregators have backend storage), you must splice (burn?) it into your blog’s feed. As a first pass, I tried Google Reader’s public feed for a tag I made of my blog feed and the daily Flickr feed, but I was unhappy with the amount of extra markup that Reader inserts. So, I went back to Pipes, which offers a Union operator to do exactly what I needed.

Since I was already running my feed through FeedBurner, I simply pointed it at the new, combined feed coming out of Pipes.

If you’re trying this using Blogger, use the Post Feed Redirect URL setting (Under Settings > Site Feed) to redirect your current subscribers to Pipes or (better yet) FeedBurner. Important note: If you do enable the Post Feed Redirect URL, you’ll need to add ?redirect=false to your feed when you fetch it via Pipes, or else Blogger will send Pipes a redirect when it tries to get the feed.

Let me know in the comments if you have any questions, or if you’re trying this out for yourself. If you’re subscribed to my feed, I hope you enjoy the photos!