Using flickr API to download photo

I have wrote a small script to download flickr photo by tags, as the


require ‘rubygems’
require ‘flickr’

flickr =

for page_iter in (1…100)
criteria = { ‘tags’ => ‘landscape’, ‘page’ => page_iter.to_s,
‘per_page’ => ‘500’ }

for photo in criteria ) photo.filename, ‘w’ ) do |file|
file.puts photo.file( ‘Original’ )


I can download about the first 25 ~ 30 photos

and I get the following error message, then the program terminated:


/var/lib/gems/1.8/gems/flickr-1.0.0/./flickr.rb:317:in source': undefined method[]’ for nil:NilClass (NoMethodError)
from /var/lib/gems/1.8/gems/flickr-1.0.0/./flickr.rb:322:in
file' from photosearch.rb:11 from photosearch.rb:10:inopen’
from photosearch.rb:10
from photosearch.rb:9:in each' from photosearch.rb:9 from photosearch.rb:6:ineach’
from photosearch.rb:6


What’s the problem?

Any idea?

On Nov 3, 2007 7:13 AM, Chung-lin Wen [email protected] wrote:

for page_iter in (1…100)

What’s the problem?


You probably don’t have permission to download the photo in its
original size. Lots of flickr users don’t allow it.

I ended up using flickraw:
instead of flickr, where you can say things like:

perms = =>
if perms.ispublic == 1

Do stuff here


Hope this helps,