Skip to content

Instantly share code, notes, and snippets.

@timriley
Created June 27, 2010 04:27
Show Gist options
  • Save timriley/454635 to your computer and use it in GitHub Desktop.
Save timriley/454635 to your computer and use it in GitHub Desktop.
Backup a photoset from flickr
#!/usr/bin/env ruby
require 'rubygems'
require 'flickraw'
require 'fileutils'
require 'open-uri'
YOUR_API_KEY = 'xxx'
SET_TO_BACKUP = 'yyy'
FlickRaw.api_key = YOUR_API_KEY
photos = flickr.photosets.getPhotos(:photoset_id => SET_TO_BACKUP, :per_page => 200)
FileUtils.mkdir_p 'flickr'
photos['photo'].each_with_index do |photo, i|
puts "Downloading ##{i}"
original = flickr.photos.getSizes(:photo_id => photo['id']).find {|s| s.label == 'Original'}
File.open("flickr/#{photo['title']}.jpg", 'w+') do |local|
local.write(open(original['source']).read)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment