Skip to content

Instantly share code, notes, and snippets.

Created Dec 6, 2012
What would you like to do?
Script to download a Flickr photoset.
#!/usr/bin/env ruby -wKU
require 'rubygems'
require 'flickraw'
require 'open-uri'
require 'fileutils'
FlickRaw.api_key = "YOUR_API_KEY"
FlickRaw.shared_secret = "YOUR_SHARED_SECRET"
photoset = ARGV.first || raise(ArgumentError, "Missing photoset")
photos = flickr.photosets.getPhotos(:photoset_id => photoset).photo
total_count = photos.size
photo_count = 0
photos.each do |photo|
photo_count += 1
puts "=> Photo #{photo_count}/#{total_count}"
puts " #{} #{photo.title}"
puts " Getting info"
info = =>, :secret => photo.secret)
url = FlickRaw.url_o(info)
name = File.basename(url)
next if File.exist?("#{photoset}/#{name}")
puts " Downloading #{url}""#{photoset}/#{name}", "wb+") { |f| f.write(open(url).read) }
puts " Saved #{photoset}/#{name}"

This comment has been minimized.

Copy link

@robertokl robertokl commented Apr 18, 2015


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment