Author Topic: Any of you got a Kodak gallery that needs rescuing before the site closes?  (Read 2023 times)

Offline Tony

  • Administrator
  • Oil baron
  • *******
  • Posts: 5108
  • Fo' shizzle, biodizzle
    • Southampton Waste Oil Collection
  • Location: Southampton
The missus tasked me with downloading all the photos from Kodak before they close down.  The US and CA sites are being migrated to another service but UK users will just lose their photos.

So the recommended way is to download Kodak Easyshare and for every Gallery, right click and select "Express Download".  If you've got hundreds of galleries this is Not Fun (tm).

I found a years-old ruby script to supposedly do this for the US site, but it didn't work with new versions of Ruby and certainly not with Ruby for Windows.  However, I've fixed it all up and it works for me now:

Quote
require 'rubygems'
require 'mechanize'
require 'fileutils'

agent = Mechanize.new
agent.agent.http.verify_mode = OpenSSL::SSL::VERIFY_NONE
signin_page = agent.get('http://www.kodakgallery.co.uk/Signin.jsp')
signin_page.forms[0].email = 'your@email.com'
signin_page.forms[0].password = 'yourpassword'
signin_page.forms[0].submit

album_page = agent.get('http://www.kodakgallery.co.uk/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.co.uk/#{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\?\:\>\<\\\/|]/, '_')

  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.co.uk/#{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.co.uk#{fullres}"
      result = agent.get(file_to_dl)
      if result.class == Mechanize::Image
        result.save
        puts "Saved #{file_to_dl}"
      else
        puts "FAIL on #{file_to_dl}"
      end
    end

  end

  puts "-----------------------------------------"
  puts "-----------------------------------------"
  puts "-----------------------------------------"
end

Put that in any directory and call it get.rb for example C:\Kodak\get.rb

- Edit the file to enter your username and password (look at the top few lines)

- Install Ruby for windows in the default place, C:\Ruby193\
  http://rubyforge.org/frs/download.php/76054/rubyinstaller-1.9.3-p194.exe

- From a command prompt run (this may take a while):
  cd C:\Ruby193\bin
  gem install hoe rake mechanize

- Run the script itself from your directory:
  cd C:\Kodak\
  C:\Ruby193\bin\ruby get.rb

If all goes well you'll have a collection of directories with your album names containing the appropriate photos.