spotify_osx_controller 2.0.1 → 2.0.2
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/bin/spotify_osx_controller +15 -4
- data/lib/spotify_osx_controller/search.rb +7 -11
- data/lib/spotify_osx_controller/version.rb +1 -1
- data/lib/spotify_osx_controller.rb +2 -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: 472671d88cff5d0ba3919bc94641e730dde3a966
|
4
|
+
data.tar.gz: 1ed10f8288b908033b19fc228708c4af6fbe4e63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6dabf9970dd4f0f6fff2749807d41dace3603544ca76bc10a9ef3000d3f79a716a555716564f31f658176f1a2900e2040980d36e634d76863bae387a61719068
|
7
|
+
data.tar.gz: 12ba5c342ab4277a71a1a913b314941e2d4a73d93f46678e54367472ed1da5cf3a64ff3593b271576dc477654c72547c88694ae055bf4fb1cdd6a0bb24b6c1c8
|
data/bin/spotify_osx_controller
CHANGED
@@ -47,16 +47,27 @@ def global_cmds (opts)
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
+
def parse (array)
|
51
|
+
array.join('+') if array
|
52
|
+
end
|
53
|
+
|
54
|
+
|
50
55
|
|
51
56
|
cmd = ARGV.shift
|
52
57
|
case cmd
|
53
58
|
when "play"
|
54
59
|
cmd_opts = Trollop::options do
|
55
|
-
opt :track, "Track to play", type: :strings, short: 't', default:
|
56
|
-
opt :artist, "Artist to play", type: :strings, short: 'a', default:
|
57
|
-
opt :album, "Album to play", type: :strings, short: 'A', default:
|
60
|
+
opt :track, "Track to play", type: :strings, short: 't', default: nil
|
61
|
+
opt :artist, "Artist to play", type: :strings, short: 'a', default: nil
|
62
|
+
opt :album, "Album to play", type: :strings, short: 'A', default: nil
|
58
63
|
end
|
59
|
-
|
64
|
+
|
65
|
+
params = Hash.new
|
66
|
+
params[:track] = parse(cmd_opts[:track]) if cmd_opts[:track]
|
67
|
+
params[:artist] = parse(cmd_opts[:artist]) if cmd_opts[:artist]
|
68
|
+
params[:album] = parse(cmd_opts[:album]) if cmd_opts[:album]
|
69
|
+
|
70
|
+
SpotifyOsxController.play params
|
60
71
|
when "play-pause"
|
61
72
|
SpotifyOsxController.play_pause
|
62
73
|
when "stop"
|
@@ -5,9 +5,9 @@ module SpotifyOsxController
|
|
5
5
|
class Search
|
6
6
|
|
7
7
|
def initialize (parameters = {})
|
8
|
-
@track =
|
9
|
-
@artist =
|
10
|
-
@album =
|
8
|
+
@track = parameters[:track]
|
9
|
+
@artist = parameters[:artist]
|
10
|
+
@album = parameters[:album]
|
11
11
|
@query = construct_query
|
12
12
|
@results = run_query
|
13
13
|
end
|
@@ -23,22 +23,18 @@ module SpotifyOsxController
|
|
23
23
|
private
|
24
24
|
|
25
25
|
def run_query ()
|
26
|
-
if
|
26
|
+
if !@track
|
27
27
|
RSpotify::Album.search @query
|
28
28
|
else
|
29
29
|
RSpotify::Track.search @query
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
def parse (array)
|
34
|
-
array.join('+') if array
|
35
|
-
end
|
36
|
-
|
37
33
|
def construct_query
|
38
34
|
query = ""
|
39
|
-
query += "artist:#{@artist} " if
|
40
|
-
query += "track:#{@track} " if
|
41
|
-
query += "album:#{@album}" if
|
35
|
+
query += "artist:#{@artist} " if @artist
|
36
|
+
query += "track:#{@track} " if @track
|
37
|
+
query += "album:#{@album}" if @album
|
42
38
|
query
|
43
39
|
end
|
44
40
|
end
|
@@ -4,10 +4,11 @@ require "spotify_osx_controller/search.rb"
|
|
4
4
|
module SpotifyOsxController
|
5
5
|
|
6
6
|
def self.play(parameters = {})
|
7
|
-
if !parameters.
|
7
|
+
if !parameters.empty?
|
8
8
|
search = Search.new(parameters)
|
9
9
|
|
10
10
|
if search.any?
|
11
|
+
puts search.first
|
11
12
|
uri = search.first.uri
|
12
13
|
buildScript "tell application \"Spotify\" to play track \"#{uri}\"\n"
|
13
14
|
else
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spotify_osx_controller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Swensson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: trollop
|