henchman-sync 0.3.0 → 0.3.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.
- checksums.yaml +4 -4
- data/lib/applescript.rb +16 -4
- data/lib/core.rb +12 -6
- data/lib/henchman/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34113b7a846cd62928aa75e9698a466ee237357f
|
4
|
+
data.tar.gz: 2b0ca4b2d1bb0212c6072c399f5ed8db8278d7a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74ca677b0cffdcc6fb94947f1a248e53ef2ca074e8b41472b92fa53d33b11e3b1bff1ae4cc2783397a33b0b45fde5ea30f0328877515d91c4a5d68514f4f49f3
|
7
|
+
data.tar.gz: bab19023bb414a722b905540479d1297ddd9fa25983c239ca112b3eb8a9114316211332a0ec49aedb8b900198f1a99103062fcb422580a2f5afa27c835ef0667
|
data/lib/applescript.rb
CHANGED
@@ -15,9 +15,20 @@ module Henchman
|
|
15
15
|
"end tell"
|
16
16
|
end
|
17
17
|
|
18
|
-
def prompt_script
|
18
|
+
def prompt_script buttons = []
|
19
|
+
buttons = buttons.slice(0..1).map { |b| "Download #{b.gsub(/'/){ %q('"'"') }}" }
|
19
20
|
"tell application \"iTunes\"\n"\
|
20
|
-
|
21
|
+
" display dialog \"\""\
|
22
|
+
" buttons {"\
|
23
|
+
" \"Cancel\""\
|
24
|
+
" #{(buttons.length > 0) ? ",\"#{buttons.first}\"" : ''}"\
|
25
|
+
" #{(buttons.length > 1) ? ",\"#{buttons.last}\"" : ''}"\
|
26
|
+
" }"\
|
27
|
+
" with title \"Henchman 🏃\""\
|
28
|
+
" cancel button \"Cancel\""\
|
29
|
+
" default button \"#{(buttons.length > 0) ? buttons.last : 'Cancel'}\""\
|
30
|
+
" giving up after 60"\
|
31
|
+
" with icon note\n"\
|
21
32
|
"end tell"
|
22
33
|
end
|
23
34
|
|
@@ -254,8 +265,9 @@ module Henchman
|
|
254
265
|
tracks
|
255
266
|
end
|
256
267
|
|
257
|
-
def fetch?
|
258
|
-
|
268
|
+
def fetch? buttons = []
|
269
|
+
resp = %x(#{applescript_command(prompt_script buttons)}).chomp
|
270
|
+
resp.split(',').first.split(':').last.split('Download ').last rescue ''
|
259
271
|
end
|
260
272
|
|
261
273
|
def get_active_app
|
data/lib/core.rb
CHANGED
@@ -36,7 +36,10 @@ module Henchman
|
|
36
36
|
if (missing_track_selected? track) && !(@cache.ignore? :artist, track[:artist])
|
37
37
|
update_cache = true
|
38
38
|
@cache.update_ignore :artist, track[:artist]
|
39
|
-
|
39
|
+
|
40
|
+
opts = ['Album', 'Track']
|
41
|
+
fetch = @appleScript.fetch? opts
|
42
|
+
if opts.include? fetch
|
40
43
|
begin
|
41
44
|
# first download the selected track
|
42
45
|
dropbox_path = @dropbox.search_for track
|
@@ -53,10 +56,13 @@ module Henchman
|
|
53
56
|
next
|
54
57
|
end
|
55
58
|
|
56
|
-
# now that we've gotten the selected track,
|
57
|
-
# to download the rest of the tracks
|
58
|
-
|
59
|
-
|
59
|
+
# now that we've gotten the selected track, if we're to also get the
|
60
|
+
# album, spawn off another process to download the rest of the tracks
|
61
|
+
# on the album - spatial locality FTW
|
62
|
+
if fetch == 'Album'
|
63
|
+
album_tracks = @appleScript.get_album_tracks_of track
|
64
|
+
threads << Thread.new{ download_tracks album_tracks }
|
65
|
+
end
|
60
66
|
end
|
61
67
|
rescue StandardError => err
|
62
68
|
puts err
|
@@ -71,7 +77,7 @@ module Henchman
|
|
71
77
|
if (!playlist_tracks.empty?) && !(@cache.ignore? :playlist, playlist)
|
72
78
|
update_cache = true
|
73
79
|
@cache.update_ignore :playlist, playlist
|
74
|
-
if @appleScript.fetch? playlist
|
80
|
+
if @appleScript.fetch?([playlist]) == playlist
|
75
81
|
threads << Thread.new{ download_tracks playlist_tracks }
|
76
82
|
end
|
77
83
|
end
|
data/lib/henchman/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: henchman-sync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Merritt
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: commander
|