Skip to content

Instantly share code, notes, and snippets.

@aaronpk
Created July 6, 2014 20:42
Show Gist options
  • Save aaronpk/758959942e197ab3d8bc to your computer and use it in GitHub Desktop.
Save aaronpk/758959942e197ab3d8bc to your computer and use it in GitHub Desktop.
An untested script to change the upload date of your Flickr photos to the date the photo was taken
require 'flickraw'
FlickRaw.api_key = ''
FlickRaw.shared_secret = ''
@flickr = FlickRaw::Flickr.new
@flickr.access_token = ''
@flickr.access_secret = ''
# Test if the access token is valid
login = @flickr.test.login
if login.username.nil?
puts "Something went wrong!"
exit
end
puts "Signed in as #{login.username}"
photosPerPage = 10
# get all photos
photos = @flickr.people.getPhotos :user_id => "me", :per_page => photosPerPage, :extras => 'description,license,date_upload,date_taken,owner_name,original_format,last_update,geo,tags,machine_tags,o_dims,views,media,path_alias,url_sq,url_t,url_s,url_m,url_z,url_l,url_o'
totalPages = photos.pages
puts "====== Found #{totalPages} pages"
(0..totalPages).each do |page|
puts "==== Beginning page #{page}"
if page > 0
photos = @flickr.people.getPhotos :user_id => "me", :page => page, :per_page => photosPerPage, :extras => 'description,license,date_upload,date_taken,owner_name,original_format,last_update,geo,tags,machine_tags,o_dims,views,media,path_alias,url_sq,url_t,url_s,url_m,url_z,url_l,url_o'
end
photos.each do |p|
args = {
'photo_id' => p.id,
'date_posted' => p.upload_date
}
puts "Setting photo date:"
puts args
begin
response = @flickr.photos.setDates args
puts response.to_hash
rescue FlickRaw::FailedResponse => e
puts "Error setting photo date"
puts e
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment