I like the flickr sidebar widget

which prompted me to upgrade my flickr account. But I really wanted to use my smugmug feed as that is my main photo site.

WordPress.com offers the flickr widget but nothing for smugmug. I tried the plain RSS sidebar widget but I only get a list of links which isn’t quite as cool.

smugmug rss feed

I created a perl script that would transform my smugmug RSS feed into a Flickr RSS feed. Smugmug uses a standard RSS 2.0 feed, while flickr uses Yahoo’s media rss. I couldn’t find an easy way to do the transformation, so I took the long way of parsing the incoming RSS feed, then creating a new one. I’m running the script on my home server, which runs quite slow at the moment, but it works. 🙂

smugmug feed in flickr widget

That’s pretty cool IMO 🙂 Here is the script, or you can download it from here:

#!/usr/bin/perl
use strict;
use LWP;
use XML::RSS;

my $req = HTTP::Request->new(GET => 'http://familiarodriguez.smugmug.com/hack/feed.mg?Type=nicknameRecentPhotos&Data=familiarodriguez&format=rss200');
my $ua = LWP::UserAgent->new;
my $resp = $ua->request($req);

# rss feed
# my $resp->content;
my $smugrss = new XML::RSS;
$smugrss->parse($resp->content);

my $s2frss = new XML::RSS;
$s2frss->add_module(prefix=>'media', uri=>'http://search.yahoo.com/mrss/');

# copy the channel
my $smugchan = $smugrss->{'channel'};
$s2frss->channel(title  => $smugchan->{'title'},
                 link   => $smugchan->{'link'},
                 description => $smugchan->{'description'},
                 pubDate => $smugchan->{'pubDate'},
                 lastBuildDate => $smugchan->{'lastBuildDate'},
                 generator => $smugchan->{'generator'},
                 copyright => $smugchan->{'copyright'});

$s2frss->image(title => $smugrss->{'image'}->{'title'},
               url   => $smugrss->{'image'}->{'url'},
               link  => $smugrss->{'image'}->{'link'});

# copy items
foreach my $item (@{$smugrss->{'items'}}) {
   $s2frss->add_item(
      title       => $item->{'title'},
      link        => $item->{'link'},
      description => $item->{'description'},
      pubDate     => $item->{'pubDate'},
      author      => $item->{'author'},
      guid        => $item->{'guid'},
      category    => $item->{'category'},
      media => {
        title     => $item->{'title'},
        text      => $item->{'description'},
        content => {
          url     => $item->{'enclosure'}->{'url'},
          type    => "image/jpeg",
          height  => "100",  # change later
          width   => "100"
        },
        thumbnail => {
          url     => $item->{'enclosure'}->{'url'},
          height  => "100",  # change later
          width   => "100"
        }
      }
   );
}

print "Content-Type: text/xmlnn";
$s2frss->{output} = "2.0";
print $s2frss->as_string;

3 thoughts on “smugmug to flickr rss

  1. just wanted to say that i have smugmug and love my flickr sidebar widget on my wordpress blog. i used the smugmug gallery feed (that i found on the Share page) and put it where the api feed thing was for flickr and it works. i just get the most recent pics, but for me that is enough. if my family wants more, they just click on the widget. this might work for other people like me who aren’t very technical computer wise. 😀

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s