Kodak Gallery is holding our photos hostage. But me and Open Source are here to bust them out! (Ruby source code included)
I used kodakgallery.com in 2004 for some photos. I was younger then. I didn't know that I shouldn't bother storing photos on one of the worst photo hosts on the Internet. I thought Kodak was a brand I could trust.
"WE DON'T WANT TO DELETE YOUR PHOTOS" says the email I got today. Fine, delete them. But only after I download them. And I'm not going to pay you $20 to get an Archive CD either.
They're well within their rights to do so (heck, everyone needs to make some money) -- but they also make it quite difficult to download these photos. If you had 200 photos, you would have to click the "Download Full Resolution" button 200 times individually. If these photos are mine, then shouldn't it be a little easier? Sorry, a product manager in some stovepiped organization said no.
A quick google search returned basically no super-easy way to download and archive these things in one fell swoop.
I thought I'd whip up this simple ruby script to download them to your local directory. It requires the 'mechanize' and Ruby 1.8.6+. Save this code to a file, e.g. "kodak_easyshare.rb", edit your username and password in the script below, then run 'ruby kodak_easyshare.rb' -- and watch the magic happen.
You own those photos. Get them. Download them. Don't let Kodak hold you hostage.
This is hereby released under MIT license.
require 'rubygems'
require 'mechanize'
require 'fileutils'
agent = WWW::Mechanize.new
signin_page = agent.get('http://www.kodakgallery.com/Signin.jsp')
signin_page.forms[0].email = 'yourlogin_at_gmail.com'
signin_page.forms[0].password = 'your_password_here'
signin_page.forms[0].submit
album_page = agent.get('http://www.kodakgallery.com/AlbumMenu.jsp?Upost_signin=Welcome.jsp')
albums = album_page.links.map{|l| (l.href.match(/BrowsePhotos.jsp/) && l.text && l.text.match(/[A-Za-z0-9]/)) ? {:href => l.href, :name => l.text} : nil}.compact
albums.each do |album_hash|
puts "\n\n\n"
puts "-----------------------------------------"
puts "'#{album_hash[:name]}'"
puts "#{album_hash[:href]}"
gallery_page = agent.get("http://www.kodakgallery.com/#{album_hash[:href]}")
photos = gallery_page.links.map{|l| (l.href.match(/PhotoView.jsp/) && !l.href.match(/javascript/)) ? l.href : nil}.compact.uniq
album_dirname = album_hash[:name].gsub(/[\n\t\?\:[[posterous_whitelist_block_0]]gt;[[posterous_whitelist_block_0]]lt;\\/|]/, '_')
unless File.exists?(album_dirname)
puts "creating album #{album_dirname}"
FileUtils.mkdir(album_dirname)
end
FileUtils.cd(album_dirname, :verbose => true) do
photos.each do |p|
photo_page = agent.get("http://www.kodakgallery.com/#{p}")
fullres = photo_page.links.map{|l| (l.href.match(/FullResDownload/) && !l.href.match(/javascript/)) ? l.href : nil}.compact.uniq.first
file_to_dl = "http://www.kodakgallery.com#{fullres}"
result = agent.get(file_to_dl)
if result.class == WWW::Mechanize::File
result.save
puts "Saved #{file_to_dl}"
else
puts "FAIL on #{file_to_dl}"
end
end
end
puts "-----------------------------------------"
puts "-----------------------------------------"
puts "-----------------------------------------"
end
37 comments
Type-checking in a duck-typed language? For serious?
FROM THIS:
album_page = agent.get('http://www.kodakgallery.com/AlbumMenu.jsp?Upost_signin=Welcome.jsp')
TO THIS:
album_page = agent.get('http://www.kodakgallery.com/AlbumMenu.jsp?Upost_signin=Welcome.jsp&albumsperpage=9999')
I'm not blaming you, I'm just saying it is pretty sick if the best way to check for a successful grab is by checking the returned class. Why wouldn't it always return the same class? Or in absence of that sensibility, None (or nil, or w/e)?
agent = WWW::Mechanize.new
to be this:
agent = WWW::Mechanize.new{ |agent|
agent.history.max_size=0
}
(learned from http://my.opera.com/dduenker/blog/2008/09/03/ruby-prevent-www-mechanize-from-stealing-your-memory )
p.s., luv that posterous displays this code so well.
I even tried to buy their Archive CD except their system can't process > 40,000 images via Archive CD.
They keep canceling my order without comment.
(Current photo storage: 62.532 GB Used,
219 galleries,
Your Archive CD Pricing:
Number of Photos: 42666
Cost of your CD: $667.85
FYI).
Works like a champ. Send me an address and I'll send you some beer or money or something.
For the last 2 hours, I have tried to figure out how to run the script posted above using Ruby. It says you need Mechanize, which has no exe to launch, so how the hell does it work.I have it downloaded, but there's no setup or exe or launch method, very F@*#@$g frustrating...Does it run with IE, or Firefox, or in the Run cmd line...What is the order to launch...Mechanize, then Ruby than the script. How do I tell that Mechanize is running. I type in the script posted above with the mono settings as mentioned ( usually default ) and it does nothing... Where does it download to, does it show a file percentage downloaded... Is Mechanize suppose to be running without notification...Forgive me as I am not a computer idiot, just have no clue how this works whatsoever !!!
I've read the articles on Ruby, Mechanize and still have no clue how or where or what should be happening on my screen or how this can work...I am in hell, please help this idiot,,,I beg you... lol : )
You would need to install the mechanize gem by first running gem install mechanize. Then you would run ruby myscript.rb.
Where and how using what program, where do I input this command... Do i have to open a program ??? Where does this go ??? Sorry, but I'm still lost !
If you still have problems, I suggest trying http://www.picwing.com/blog/?p=1457 -- there's no setup involved, and we know those guys and they're awesome!
Help please : (
Its Edward from Picwing. I just tested our kodak gallery import program and didn't see any problems. It's possible that Kodak already deleted your photos so we couldn't find anything to import =(. Send me an email and i'll try to help you out.
That would be awesome if you could.
Below:
http://classic.kodakgallery.com/Signin.jsp?
I got past the login but still having troubles, hope this helps if you don't mind updating your script.
I'll report back, later with the new code. Just want to see if it works well!
I updated your code and got it to work. Here's what I did:
1. updated the agent code to avoid memory problems (thx @turbodingo)
agent = WWW::Mechanize.new{ |agent|
agent.history.max_size=0
}
2. updated albums per page (thx @turbodingo's) since i have more than 16 albums
album_page = agent.get('http://www.kodakgallery.com/AlbumMenu.jsp?Upost_signin=Welcome.jsp&albumsperpage=999
3. updated the kodakgallery urls from www.kodakgallery.com to classic.kodaygallery.com
Even posted a tutorial how to do it on a windows machine.
http://www.computerrich.com/news/kodak-gallery-download-ruby-script-windows-automation-tool/
thanks

