Skip to content

Instantly share code, notes, and snippets.

@pkulak
Last active March 9, 2017 16:04
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pkulak/a20196f68f7c88f1d7e0 to your computer and use it in GitHub Desktop.
Save pkulak/a20196f68f7c88f1d7e0 to your computer and use it in GitHub Desktop.
A simple script to get the files off your Olympus camera.
#!/usr/bin/env ruby
require 'open-uri'
require 'time'
require 'json'
class Runner
def initialize
@base = "http://192.168.0.10/DCIM/100OLYMP"
# Replace this with wherever you'd like your photos to live.
@home = File.join(Dir.home, "/Google Drive/Photo Sync/Negatives/#{DateTime.now.year}/#{DateTime.now.strftime("%m")}")
@config = File.join(Dir.home, "/.imported_photos")
unless Dir.exist?(@home)
Dir.mkdir(@home)
end
if File.exist?(@config)
@seen = JSON.parse(IO.read(@config))
else
@seen = []
end
end
def run
page = open(@base).read
last_ext = ""
page.split("\n").each do |line|
next unless line.start_with?("wlansd[")
file = line[11...-3].split(",")[1]
if @seen.include?(file)
puts "skipping file #{file}"
next
end
`curl #{@base}/#{file} > "#{@home}/#{file}"`
@seen << file
end
File.open(@config, 'w') {|file| file.write(@seen.to_json)}
end
end
Runner.new.run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment