photo-helper 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6ebc81166744455f3d5beb78c36becd87c84b9ec
4
- data.tar.gz: 64f264c31fbe8cb8567a26898f604f90fed5641e
3
+ metadata.gz: 872ff4ca51d026c5d2989c1f963ea9bd61d6d253
4
+ data.tar.gz: c14da101067339ee1f280487a89a812c41e28c95
5
5
  SHA512:
6
- metadata.gz: 1319f5edfb2d865bd36a5e2a3bc925b72a55e65aaf14527907b210f816c5d45d9a60c660c89c9661dc23952bb8f9cceba7e4ddc203f48fadf72b8f052d129a04
7
- data.tar.gz: ad76247a736ad38f397945721cd79f18c6c517ecd9d7345a707e346990eafb7be969f2ba38b0eac38cd58b8b15a9263439754b7019752336a0ea1bc7a6e414e9
6
+ metadata.gz: 047bce5bf33f8b21db4a162e5b50850ada553b4f49c0c43a6d8a55a3200902afda0ec505248c2625abc4e972c275e72104faeb885946325b5b8e5f730f5935a2
7
+ data.tar.gz: 39ae529a24cd3e492fe5440817f860fe0e965d0062b32d8bb39376af777e3467ceb7574fc0b8d94c01081ab831f9563957272d2dcf629d7e941aaaed9869cc0a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- photo-helper (0.1.2)
4
+ photo-helper (0.1.4)
5
5
  thor
6
6
 
7
7
  GEM
@@ -56,4 +56,4 @@ DEPENDENCIES
56
56
  rubocop
57
57
 
58
58
  BUNDLED WITH
59
- 1.15.3
59
+ 1.15.4
@@ -0,0 +1,9 @@
1
+ class FileHelper
2
+ def self.directory(path)
3
+ File.dirname(path).split("/").last
4
+ end
5
+
6
+ def self.ingore_file?(path)
7
+ IGNORE_FOLDERS.include? directory(path).downcase
8
+ end
9
+ end
@@ -20,8 +20,6 @@ module PhotoHelper
20
20
  search_path = File.expand_path(folder)
21
21
  jpeg_path = File.join(search_path, "jpegs")
22
22
 
23
- Dir.mkdir(jpeg_path) unless File.exist?(jpeg_path)
24
-
25
23
  files =
26
24
  if options[:recursive]
27
25
  Dir["#{search_path}/**/*.#{JPEG_EXTENSION}"]
@@ -42,7 +40,7 @@ module PhotoHelper
42
40
  end
43
41
  end
44
42
 
45
- next unless File.exist?(jpeg_path) && yes?("Delete jpeg folder?")
43
+ return unless File.exist?(jpeg_path) && yes?("Delete jpeg folder?")
46
44
  say "Deleting jpeg folder", :red
47
45
  if options[:hard]
48
46
  File.delete(jpeg_path)
@@ -1,3 +1,5 @@
1
+ # exiftool -b -previewimage 2017-09-24-seattle-23.ORF>hi.jpg
2
+
1
3
  module PhotoHelper
2
4
  class Generate < Thor
3
5
  include Thor::Actions
@@ -0,0 +1,58 @@
1
+ require "helpers/file_helper"
2
+
3
+ module PhotoHelper
4
+ class Instagram < Thor
5
+ include Thor::Actions
6
+
7
+ def self.folders
8
+ ["instagram"]
9
+ end
10
+
11
+ def self.album
12
+ "Instagram"
13
+ end
14
+
15
+ desc "load", "load all pictures in instagram folders into apple photos"
16
+
17
+ method_option :recursive, aliases: "-r", type: :boolean, default: false
18
+ method_option :folder, aliases: "-f", type: :string, default: "."
19
+
20
+ def self.osascript(script)
21
+ system 'osascript', *script.split(/\n/).map { |line| ['-e', line] }.flatten
22
+ end
23
+
24
+ def load(folder=nil)
25
+ folder ||= options[:folder]
26
+
27
+ search_path = File.expand_path(folder)
28
+
29
+ files =
30
+ if options[:recursive]
31
+ Dir["#{search_path}/**/*"]
32
+ else
33
+ Dir["#{search_path}/*"]
34
+ end
35
+
36
+ pictures = []
37
+
38
+ files.each do |file|
39
+ folder = FileHelper.directory(file)
40
+ next unless PhotoHelper::Instagram.folders.include? (folder)
41
+ pictures.concat([file])
42
+ end
43
+ puts pictures
44
+ PhotoHelper::Instagram.osascript <<-END
45
+ tell application "Photos"
46
+ activate
47
+ delay 2
48
+ set ablum to get album "#{PhotoHelper::Instagram.album}"
49
+ set imageList to {"#{pictures.join('","')}"}
50
+ import imageList into ablum skip check duplicates no
51
+ end tell
52
+ END
53
+
54
+ end
55
+
56
+ default_task :load
57
+ end
58
+ end
@@ -0,0 +1,43 @@
1
+ require "helpers/trash"
2
+ require 'fileutils'
3
+ require 'helpers/file_helper'
4
+
5
+ module PhotoHelper
6
+ class Move < Thor
7
+ include Thor::Actions
8
+
9
+ map "j" => "jpeg"
10
+ map "jpg" => "jpeg"
11
+ map "jpgs" => "jpeg"
12
+ map "jpegs" => "jpeg"
13
+
14
+ desc "jpeg", "delete jpegs that have an raw with same name"
15
+ method_option :folder, aliases: "-f", type: :string, default: "."
16
+ method_option :recursive, aliases: "-r", type: :boolean, default: false
17
+ def jpeg(folder = nil)
18
+ folder ||= options[:folder]
19
+ puts folder
20
+
21
+ search_path = File.expand_path(folder)
22
+
23
+ files =
24
+ if options[:recursive]
25
+ Dir["#{search_path}/**/*.#{JPEG_EXTENSION}"]
26
+ else
27
+ Dir["#{search_path}/*.#{JPEG_EXTENSION}"]
28
+ end
29
+
30
+ files.each do |file|
31
+ next if FileHelper.ingore_file?(file)
32
+ relative_path = Pathname.new(file).relative_path_from(Pathname.new(PHOTOS_ROOT)).to_s
33
+ new_path = File.join(JPEG_ROOT, relative_path)
34
+ path_dir = File.dirname(new_path)
35
+
36
+ FileUtils.mkdir_p path_dir unless File.exists? path_dir
37
+
38
+ FileUtils.mv file, new_path
39
+
40
+ end
41
+ end
42
+ end
43
+ end
@@ -1,3 +1,3 @@
1
1
  module KubeDeploy
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.4"
3
3
  end
data/lib/photo_helper.rb CHANGED
@@ -5,10 +5,16 @@ require 'helpers/printer'
5
5
  require 'photo-helper/version'
6
6
  require 'photo-helper/generate'
7
7
  require 'photo-helper/delete'
8
+ require 'photo-helper/move'
9
+ require 'photo-helper/instagram'
8
10
 
9
11
  # todo: move to config file
10
- RAW_EXTENSION = "ORF"
12
+ # RAW_EXTENSION = "ORF"
13
+ RAW_EXTENSION = "dng"
11
14
  JPEG_EXTENSION = "JPG"
15
+ PHOTOS_ROOT = "/Users/benjamincaldwell/Pictures/Pictures"
16
+ JPEG_ROOT ="/Users/benjamincaldwell/Pictures/jpegs"
17
+ IGNORE_FOLDERS = ["instagram", "exported", "edited"]
12
18
 
13
19
  module PhotoHelper
14
20
  class CLI < Thor
@@ -19,9 +25,10 @@ module PhotoHelper
19
25
  def version
20
26
  puts KubeDeploy::VERSION
21
27
  end
22
- # default_task :version
23
28
 
24
29
  register PhotoHelper::Generate, :generate, "generate", "Do something else"
25
30
  register PhotoHelper::Delete, :delete, "delete", "Do something else"
31
+ register PhotoHelper::Instagram, :instagram, "instagram", "Do something else"
32
+ register PhotoHelper::Move, :move, "move", "Do something else"
26
33
  end
27
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: photo-helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Caldwell
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-16 00:00:00.000000000 Z
11
+ date: 2017-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -140,10 +140,13 @@ files:
140
140
  - bin/photo-helper
141
141
  - bin/setup
142
142
  - exe/photo-helper
143
+ - lib/helpers/file_helper.rb
143
144
  - lib/helpers/printer.rb
144
145
  - lib/helpers/trash.rb
145
146
  - lib/photo-helper/delete.rb
146
147
  - lib/photo-helper/generate.rb
148
+ - lib/photo-helper/instagram.rb
149
+ - lib/photo-helper/move.rb
147
150
  - lib/photo-helper/version.rb
148
151
  - lib/photo_helper.rb
149
152
  - photo-helper.gemspec