icloud-photo 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0e1f189419d974adfba153c99870f84786970e74
4
+ data.tar.gz: aef7c605e6a185c7f6001a9d998cd1642659d3c5
5
+ SHA512:
6
+ metadata.gz: cb7c0a39234ae12d123c9c855c61438b3382fd322bdd9bbd0a6933eb4480792ffa5595f03a743c5c22ce8edc56d1db7fdd479534218749b6e97b9372948c443a
7
+ data.tar.gz: 8e32e6862755e36a25b770ae5d4360d614cb050d7ca856dd8c7434906c872beadd8de9c506ac121cf59caddf1f48dc071e9e8d6c202d8e57f86a3fcfa9ab28ff
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in icloud-photo.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Brian Leonard
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,6 @@
1
+ # ICloudPhoto::Sync
2
+
3
+ So you want to send photos to your photo stream on iCloud. I looked for an API and couldn't find one.
4
+ So I made this mess. It uses AppleScript to launch iPhoto and then puppeteers it until the photos are in iPhoto.
5
+
6
+
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'icloud_photo/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "icloud-photo"
8
+ spec.version = ICloudPhoto::VERSION
9
+ spec.authors = ["Brian Leonard"]
10
+ spec.email = ["brian@bleonard.com"]
11
+ spec.summary = %q{Uses iPhoto on a Mac to send pictures to iCloud.}
12
+ spec.description = %q{There seem to be no APIs to upload photos to iCloud, so here is a hack.}
13
+ spec.homepage = "https://github.com/taskrabbit/icloud-photo"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
@@ -0,0 +1,85 @@
1
+ tell application "iPhoto"
2
+ quit
3
+ delay 10
4
+
5
+ activate
6
+ tell album "Photos"
7
+ set thePhotos to get every photo
8
+ repeat with aPhoto in thePhotos
9
+ try
10
+ -- log aPhoto's name as text
11
+ remove aPhoto
12
+ on error errMsg
13
+ log "ERROR: " & errMsg
14
+ end try
15
+ end repeat
16
+ end tell
17
+
18
+ set iFolder to "/Users/dashboard/screenshots"
19
+ import photo from iFolder
20
+
21
+ delay 2
22
+
23
+ tell me to refreshCloud("dashboard", {"sampletv"})
24
+
25
+ empty trash
26
+ delay 10
27
+ quit
28
+ end tell
29
+
30
+ on refreshCloud(cloudName, thePhotos)
31
+ tell application "iPhoto"
32
+ set currentPhotos to {}
33
+ set hasHold to false
34
+ tell album cloudName
35
+ set cloudPhotos to get every photo
36
+ repeat with aPhoto in cloudPhotos
37
+ if name of aPhoto is "hold"
38
+ set hasHold to true
39
+ else
40
+ set the end of currentPhotos to aPhoto
41
+ end if
42
+ end repeat
43
+ end tell
44
+
45
+ repeat with aName in thePhotos
46
+ tell album "Last Import" to select photo aName
47
+ delay 1
48
+
49
+ tell application "System Events"
50
+ tell process "iPhoto"
51
+ click menu item "iCloud…" of menu "Share" of menu bar 1
52
+ delay 1
53
+
54
+ keystroke cloudName
55
+ delay 1
56
+
57
+ keystroke (ASCII character 13) -- return
58
+ delay 1
59
+
60
+ keystroke (ASCII character 13) -- return
61
+ delay 3
62
+ end tell
63
+ end tell
64
+ end repeat
65
+
66
+ select album cloudName
67
+ if not hasHold
68
+ -- need to let iCloud catch up
69
+ delay 100
70
+ end if
71
+ if (count of currentPhotos) > 0 then
72
+ repeat with aPhoto in currentPhotos
73
+ select aPhoto
74
+ tell application "System Events"
75
+ delay 1
76
+ keystroke (ASCII character 127) -- delete
77
+ delay 1
78
+ keystroke "d" using command down -- yes, really
79
+ delay 3
80
+ end tell
81
+ end repeat
82
+ end if
83
+
84
+ end tell
85
+ end refreshCloud
@@ -0,0 +1,6 @@
1
+ require "icloud_photo/version"
2
+
3
+ module ICloudPhoto
4
+ autoload "Sync", "icloud_photo/sync"
5
+ end
6
+
@@ -0,0 +1,54 @@
1
+ # encoding: utf-8
2
+
3
+ require 'fileutils'
4
+ require 'tempfile'
5
+
6
+ module ICloudPhoto
7
+ class Sync
8
+
9
+ SCRIPT = File.read(File.expand_path("../../applescript/sync.applescript", __FILE__), encoding: "UTF-8")
10
+ def initialize(directory)
11
+ @directory = directory
12
+ @targets = []
13
+ end
14
+
15
+ def add(icloud_name, image_names)
16
+ image_names = [image_names].flatten
17
+ @targets << [icloud_name, image_names]
18
+ end
19
+
20
+ def upload!
21
+ tmpfile = nil
22
+ uploader = nil
23
+ script = SCRIPT.dup
24
+ script.gsub!("/Users/dashboard/screenshots", File.expand_path(@directory))
25
+
26
+ marker = 'tell me to refreshCloud("dashboard", {"sampletv"})'
27
+ index = script.index(marker) + 1
28
+ script.gsub!(marker, '')
29
+
30
+ @targets.each do |tuple|
31
+ icloud_name, image_names = tuple
32
+ files = image_names.collect{ |name| "\"#{name}\"" }
33
+ val = "\ttell me to refreshCloud(\"#{icloud_name}\", {#{files.join(", ")}})\n"
34
+ script.insert(index, val)
35
+ end
36
+
37
+ tmpfile = Tempfile.new('applescript')
38
+ tmpfile.write(script)
39
+ tmpfile.close
40
+
41
+ uploader = Tempfile.new('uploader')
42
+ uploader.close
43
+
44
+ puts "osacompile -o #{uploader.path} #{tmpfile.path}"
45
+ puts `osacompile -o #{uploader.path} #{tmpfile.path}`
46
+
47
+ puts "osascript #{uploader.path}"
48
+ puts `osascript #{uploader.path}`
49
+ ensure
50
+ tmpfile.unlink if tmpfile
51
+ uploader.unlink if uploader
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,3 @@
1
+ module ICloudPhoto
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: icloud-photo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Brian Leonard
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: There seem to be no APIs to upload photos to iCloud, so here is a hack.
42
+ email:
43
+ - brian@bleonard.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - icloud-photo.gemspec
54
+ - lib/applescript/sync.applescript
55
+ - lib/icloud-photo.rb
56
+ - lib/icloud_photo/sync.rb
57
+ - lib/icloud_photo/version.rb
58
+ homepage: https://github.com/taskrabbit/icloud-photo
59
+ licenses:
60
+ - MIT
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.2.2
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: Uses iPhoto on a Mac to send pictures to iCloud.
82
+ test_files: []