olympus-camera-dl 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1a6b1809246a4b0d1f3266fec95914929fdab81c04069383708fd7fbc909b850
4
+ data.tar.gz: d2ed7d8a29dab5453f9ada421d2972cb085ed54157cad337fbcf64b7e50c8a14
5
+ SHA512:
6
+ metadata.gz: 29cd1ec4fa66653c4ffbce9d695488f94b977d349234b11f5c7591a69458c588987ef48224b5ef7a226a7995a7987817c9540f89d450ef84b756ae9ed09e4fdf
7
+ data.tar.gz: 1ee2024435702cf18bb62da1b6f534cb3fb01c037b03555f9069d25713ecb7dd9ea48d0ef9bfb2b1ea1b4131a90e9fa550f4223fa0374b6f59fe30b064420a7e
@@ -0,0 +1,71 @@
1
+ ### https://raw.github.com/github/gitignore/218a941be92679ce67d0484547e3e142b2f5f6f0/Ruby.gitignore
2
+
3
+ *.gem
4
+ *.rbc
5
+ /.config
6
+ /coverage/
7
+ /InstalledFiles
8
+ /pkg/
9
+ /spec/reports/
10
+ /spec/examples.txt
11
+ /test/tmp/
12
+ /test/version_tmp/
13
+ /tmp/
14
+
15
+ # Used by dotenv library to load environment variables.
16
+ # .env
17
+
18
+ # Ignore Byebug command history file.
19
+ .byebug_history
20
+
21
+ ## Specific to RubyMotion:
22
+ .dat*
23
+ .repl_history
24
+ build/
25
+ *.bridgesupport
26
+ build-iPhoneOS/
27
+ build-iPhoneSimulator/
28
+
29
+ ## Specific to RubyMotion (use of CocoaPods):
30
+ #
31
+ # We recommend against adding the Pods directory to your .gitignore. However
32
+ # you should judge for yourself, the pros and cons are mentioned at:
33
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
34
+ #
35
+ # vendor/Pods/
36
+
37
+ ## Documentation cache and generated files:
38
+ /.yardoc/
39
+ /_yardoc/
40
+ /doc/
41
+ /rdoc/
42
+
43
+ ## Environment normalization:
44
+ /.bundle/
45
+ /vendor/bundle
46
+ /lib/bundler/man/
47
+
48
+ # for a library or gem, you might want to ignore these files since the code is
49
+ # intended to run in multiple environments; otherwise, check them in:
50
+ Gemfile.lock
51
+ # .ruby-version
52
+ # .ruby-gemset
53
+
54
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
55
+ .rvmrc
56
+
57
+ # Used by RuboCop. Remote config files pulled in from inherit_from directive.
58
+ # .rubocop-https?--*
59
+
60
+
61
+ /.bundle/
62
+ /.yardoc
63
+ /_yardoc/
64
+ /coverage/
65
+ /doc/
66
+ /pkg/
67
+ /spec/reports/
68
+ /tmp/
69
+
70
+ # rspec failure tracking
71
+ .rspec_status
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in olympus-camera-dl.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ # gem "rspec", "~> 3.0"
8
+
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Yuichi Tateno
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,49 @@
1
+ # olympus-camera-dl
2
+
3
+ cli tool that download images from olympus camera using wifi.
4
+
5
+ ## Installation
6
+
7
+ using rubygems
8
+
9
+ ```
10
+ gem install olympus-camera-dl
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```
16
+ $ olympus-camera-dl -h
17
+ Usage: olympus-camela-dl [options] ./photo-download-dir/
18
+ --delete delete images on camera after download
19
+ -c, --card-slot [NUM] set SD card slot 1 or 2
20
+ -e, --ext [EXTNAME] set download ext name, example: -e "jpg" or -e "oft"
21
+ -s, --skip skip download image when image exists
22
+ -p, --power-off camera power off when finished
23
+ ```
24
+
25
+ ```
26
+ $ olympus-camera-dl
27
+ ERROR: Can't connect to camera
28
+
29
+ ## connect to camera's wifi
30
+
31
+ $ olympus-camera-dl -c 2 --delete --power-off /home/pi/photos/E-M1MarkII/
32
+ Connected: E-M1MarkII
33
+ Target camera 11 images found
34
+ [1/11] DOWNLOAD: /DCIM/101OLYMP/PB202134.JPG
35
+ [1/11] WRITE: /home/pi/photos/E-M1MarkII/PB202134.JPG (4,517,267 byte)
36
+ [1/11] DELETED: /DCIM/101OLYMP/PB202134.JPG on camera
37
+ [2/11] DOWNLOAD: /DCIM/101OLYMP/PB202135.JPG
38
+ [2/11] WRITE: /home/pi/photos/E-M1MarkII/PB202135.JPG (4,380,822 byte)
39
+ [2/11] DELETED: /DCIM/101OLYMP/PB202135.JPG on camera
40
+ ...
41
+ [11/11] DOWNLOAD: /DCIM/101OLYMP/PB202144.JPG
42
+ [11/11] WRITE: /home/pi/photos/E-M1MarkII/PB202144.JPG (4,466,991 byte)
43
+ [11/11] DELETED: /DCIM/101OLYMP/PB202144.JPG on camera
44
+ Power off
45
+ ```
46
+
47
+ ## License
48
+
49
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,4 @@
1
+ require "bundler/gem_tasks"
2
+ #require "rspec/core/rake_task"
3
+ #RSpec::Core::RakeTask.new(:spec)
4
+ #task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "olympus/camera/dl"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,107 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "olympus-camera"
4
+ require "optparse"
5
+ require "pathname"
6
+
7
+ Signal.trap(:INT) { exit 1 }
8
+
9
+ options = {}
10
+
11
+ opt = OptionParser.new
12
+
13
+ opt.on("--delete", "delete images on camera after download") {
14
+ options[:delete] = true
15
+ }
16
+
17
+ opt.on("-c [NUM]", "--card-slot [NUM]", "set SD card slot 1 or 2") { |n|
18
+ options[:slot] = n
19
+ }
20
+
21
+ opt.on("-e [EXTNAME]", "--ext [EXTNAME]", 'set download ext name, example: -e "jpg" or -e "oft"') { |n|
22
+ options[:ext] = n.upcase
23
+ }
24
+
25
+ opt.on("-s", "--skip", "skip download image when image exists") {
26
+ options[:skip] = true
27
+ }
28
+
29
+ opt.on("-p", "--power-off", "camera power off when finished") {
30
+ options[:power_off] = true
31
+ }
32
+
33
+ opt.banner = "Usage: olympus-camela-dl [options] ./photo-download-dir/"
34
+
35
+ opt.parse!(ARGV)
36
+ options[:download_dir] = ARGV[0]
37
+
38
+ download_dir = Pathname.new(options[:download_dir] || Dir.pwd)
39
+
40
+ if !download_dir.exist?
41
+ download_dir.mkpath
42
+ end
43
+
44
+ begin
45
+ camera = OlympusCamera.new
46
+ rescue Net::OpenTimeout => e
47
+ warn "ERROR: Can't connect to camera"
48
+ exit 1
49
+ end
50
+
51
+ model = camera.get_caminfo["model"]
52
+ puts "Connected: #{model[0]}"
53
+
54
+ if options[:slot]
55
+ if camera.respond_to? :set_playtargetslot
56
+ camera.set_playtargetslot({ "targetslot" => options[:slot] })
57
+ else
58
+ puts "Can't call camera.set_playtargetslot API, skip"
59
+ end
60
+ end
61
+
62
+ images = camera.all_images.select { |image|
63
+ if options[:ext]
64
+ File.extname(image).sub(".", "").upcase === options[:ext]
65
+ else
66
+ true
67
+ end
68
+ }
69
+
70
+ def num_format(n)
71
+ n.to_s.reverse.scan(/(..?.?)/).join(",").reverse
72
+ end
73
+
74
+ puts "Target camera #{images.length} images found"
75
+
76
+ if options[:delete]
77
+ if !camera.respond_to? :exec_erase
78
+ puts "Can't call camera.exec_erase API, skip delete images"
79
+ options[:delete] = false
80
+ end
81
+ end
82
+
83
+ images.each_with_index do |image, index|
84
+ counter = "[#{index + 1}/#{images.length}]"
85
+ path = download_dir.join(image.split("/")[-1])
86
+ if options[:skip] && path.exist?
87
+ puts "#{counter} Found image #{path.realpath}, skip"
88
+ next
89
+ end
90
+ puts "#{counter} DOWNLOAD: #{image}"
91
+ data = camera.get_image(image)
92
+ puts "#{counter} WRITE: #{path} (#{num_format(data.size)} byte)"
93
+ path.open("w") { |f| f.puts data }
94
+ if options[:delete]
95
+ camera.exec_erase({ "DIR" => image })
96
+ puts "#{counter} DELETED: #{image} on camera"
97
+ end
98
+ end
99
+
100
+ if options[:power_off]
101
+ if !camera.respond_to? :exec_pwoff
102
+ puts "Can't call camera.exec_pwoff API, skip power off"
103
+ else
104
+ puts "Power off"
105
+ camera.exec_pwoff()
106
+ end
107
+ end
@@ -0,0 +1,30 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = "olympus-camera-dl"
3
+ spec.version = "0.1.0"
4
+ spec.authors = ["Yuichi Tateno"]
5
+ spec.email = ["hotchpotch@gmail.com"]
6
+
7
+ spec.summary = %q{cli tool that download images from olympus camera}
8
+ spec.description = spec.summary
9
+ spec.homepage = "https://github.com/hotchpotch/olympus-camera-dl"
10
+ spec.license = "MIT"
11
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
12
+
13
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
14
+
15
+ spec.metadata["homepage_uri"] = spec.homepage
16
+ # spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
17
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
18
+
19
+ # Specify which files should be added to the gem when it is released.
20
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
+ spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
22
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
+ end
24
+ spec.bindir = "exe"
25
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
+ spec.require_paths = ["lib"]
27
+
28
+ spec.add_dependency "olympus-camera", "~> 0"
29
+ spec.add_development_dependency "rake", "~> 12.0"
30
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: olympus-camera-dl
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Yuichi Tateno
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-11-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: olympus-camera
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '12.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '12.0'
41
+ description: cli tool that download images from olympus camera
42
+ email:
43
+ - hotchpotch@gmail.com
44
+ executables:
45
+ - olympus-camera-dl
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - bin/console
55
+ - bin/setup
56
+ - exe/olympus-camera-dl
57
+ - olympus-camera-dl.gemspec
58
+ homepage: https://github.com/hotchpotch/olympus-camera-dl
59
+ licenses:
60
+ - MIT
61
+ metadata:
62
+ homepage_uri: https://github.com/hotchpotch/olympus-camera-dl
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: 2.5.0
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubygems_version: 3.1.2
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: cli tool that download images from olympus camera
82
+ test_files: []