Search
Me

Developer for Forward. Former Technical Lead at ThoughtWorks.

Recent Comments
Elsewhere
« Online Aperture Backup | Main | Double Christmas Bonus »
Sunday
31Dec2006

Mephisto Flickr Update

Thank’s to Nathaniel Brown for pointing this out.

A few days ago Flickr seemed to change their URL scheme for images served inside their RSS feed. The Mephisto plugin I wrote included the Flickr aggregation library from Typo. This does some regular expression parsing to determine the URL for other image sizes, but, because Flickr had changed their URL scheme, it broke.

Fortunately, the fix is pretty straightforward. Of course, first the test to show the new behaviour of Flickr:




1
2
3
4
5
6
7
8
def test_should_generate_correct_address_for_each_image_size
pic = FlickrAggregation::Picture.new(
:title => 'test',
:description => 'http://farm1.static.flickr.com/my_image_m.jpg'
)

assert_equal 'http://farm1.static.flickr.com/my_image_m.jpg', pic.image
assert_equal 'http://farm1.static.flickr.com/my_image_d.jpg', pic.medium

Running the test shows that we get an error - the regular expression fails to pick up the URL correctly:

NoMethodError: You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.first

So, we change our aggregation library to fix it as:




1
2
3
def image
description.scan( /(http:\/\/.*(static|photos).*?\.jpg)/ ).first.first
end

Run the test again and we’re green.

I’ve committed the changes into the Subversion repository. So feel free to get the update!

Incidentally, I wonder whether this is related to Ezra Zygmuntowicz’s post about speeding up page loads by serving images from cnames. Maybe it’s just coincidence.

Reader Comments (3)

Erm, your engross.org domain seems to have lapsed ...

September 8, 2008 | Unregistered Commenterrobl

Yeah- sorry about that... well noticed :)

The source is still available from here: http://svn.oobaloo.co.uk/svn/mephisto_plugins/mephisto_flickr_photo_stream/trunk/

But, I'm not sure how up-to-date it is- it may well need a few minor changes to work against the latest releases of Mephisto.

September 8, 2008 | Unregistered CommenterPaul

Your idea just about this post is superb and different people will take that for their dissertation international. And some of students permanently utilize the support of thesis service.

January 6, 2010 | Unregistered CommenterKrista27

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>