Using flickr API to download photo

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

···

=======================================

require 'rubygems'
require 'flickr'

flickr = Flickr.new

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

  for photo in flickr.photos( criteria )
    File.open( photo.filename, 'w' ) do |file|
      file.puts photo.file( 'Original' )
    end
  end
end

=======================================

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:in `open'
        from photosearch.rb:10
        from photosearch.rb:9:in `each'
        from photosearch.rb:9
        from photosearch.rb:6:in `each'
        from photosearch.rb:6

=======================================

What's the problem?

Any idea?
--
Posted via http://www.ruby-forum.com/.

Hi,

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: http://raa.ruby-lang.org/project/flickraw/
instead of flickr, where you can say things like:

perms = flickr.photos.getPerms(:photo_id => photo.id)
if perms.ispublic == 1
  # Do stuff here
end

Hope this helps,

Matt

···

On Nov 3, 2007 7:13 AM, Chung-lin Wen <jonathan.clwen@gmail.com> wrote:

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

=======================================

require 'rubygems'
require 'flickr'

flickr = Flickr.new

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

  for photo in flickr.photos( criteria )
    File.open( photo.filename, 'w' ) do |file|
      file.puts photo.file( 'Original' )
    end
  end
end

=======================================

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:in `open'
        from photosearch.rb:10
        from photosearch.rb:9:in `each'
        from photosearch.rb:9
        from photosearch.rb:6:in `each'
        from photosearch.rb:6

=======================================

What's the problem?

--
Grotesque but useful, like a chair made of antlers.
-- Thomas Harris - Red Dragon
Matt Foster | http://my-mili.eu/matt