lib/flickr_airlift.rb in flickr_airlift-0.3.4 vs lib/flickr_airlift.rb in flickr_airlift-0.3.5
- old
+ new
@@ -24,15 +24,14 @@
rescue Exception => e
puts "Hmmmm - unknown user - make sure to use the user's full handle - not the one in the URL. (example: 'Fast & Bulbous' not 'fastandbulbous')"
self.download
end
+ photos = flickr.photos.search(:user_id => user_id)
+ photo_count = photos.total
+ page_count = photos.pages
- photos = flickr.photos.search(:user_id => user_id)
- photo_count = photos.total
- page_count = photos.pages
-
# non-pro users don't have 'Original' sizes available.
ranked_sizes = ['Original', 'Large', 'Medium']
# Downloading
puts "#{scraped_user} has #{photo_count} pictures"
@@ -42,17 +41,16 @@
(1..page_count.to_i).each do |page_number|
puts "* PAGE #{page_number} of #{page_count}"
flickr.photos.search(:user_id => user_id, :page => page_number).each_with_index do |photo, i|
photo_id = photo.id
- info = flickr.photos.getInfo(:photo_id => photo_id)
downloadable_files = flickr.photos.getSizes(:photo_id => photo_id)
ranked_sizes.each do |size_name|
if df = downloadable_files.find { |downloadable_file| downloadable_file.label == size_name }
- download_url = df.source
- file_to_write = File.join(scraped_user, "#{photo_id}#{File.extname(download_url)}")
+ download_url = df.source
+ file_to_write = File.join(scraped_user, "#{photo_id}#{File.extname(download_url)}")
if File.exists?(file_to_write) && File.size(file_to_write) > 0
puts "** SKIPPING #{file_to_write} because it has already been downloaded"
else
puts "** Downloading #{i+1}: #{photo.title} (#{size_name}) from #{download_url}"
@@ -104,11 +102,11 @@
puts "Delete the file and try again."
exit
end
else
- frob = flickr.auth.getFrob
- auth_url = FlickRaw.auth_url :frob => frob, :perms => "write"
+ frob = flickr.auth.getFrob
+ auth_url = FlickRaw.auth_url :frob => frob, :perms => "write"
puts " "
puts "opening your browser..."
sleep 1
puts "Come back and press Enter when you are finished"