Created
January 20, 2010 07:36
-
-
Save naoto/281686 to your computer and use it in GitHub Desktop.
Flickr Uploader
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 'flickr' | |
require 'fileutils' | |
api_key = "" | |
secret = "" | |
flickr = Flickr.new('flickr.dat',api_key, secret) | |
unless flickr.auth.token | |
flickr.auth.getFrob | |
url = flickr.auth.login_link | |
puts "Acccess! #{url} " | |
gets | |
flickr.auth.getToken | |
flickr.auth.cache_token | |
end | |
Dir.glob('*.{JPG,jpg,jpeg,png}').each do |f| | |
begin | |
flickr.photos.upload.upload_file(f, f) | |
puts "#{Time.now} upload success #{f}" | |
FileUtils.cp("./#{f}", "../uploded/#{f}") | |
File.delete("./#{f}") | |
rescue | |
puts "#{Time.now} error raised" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment