Created
June 27, 2010 04:27
-
-
Save timriley/454635 to your computer and use it in GitHub Desktop.
Backup a photoset from flickr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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