spotify_osx_controller 1.0.0 → 2.0.0
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/.gitignore +2 -1
- data/README.md +14 -13
- data/bin/spotify_osx_controller +76 -38
- data/lib/spotify_osx_controller/search.rb +43 -0
- data/lib/spotify_osx_controller/version.rb +1 -1
- data/lib/spotify_osx_controller.rb +12 -3
- data/spotify_osx_controller.gemspec +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5382df5adfa86b5ad63d2b7be7c8a5f677290ada
|
4
|
+
data.tar.gz: f7d85d51e1cc85b777502fc491e19655a4077444
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b2c4eafede4cfa62eda1d0737f9a8eb8cf8cd64d22b0e7d629b58e464fe03c6b9845914c6c29e4972284c970c82b1c1c0c3a861b69ea6d9709ae987674144ed
|
7
|
+
data.tar.gz: 1551684368962b225448391397fecd70023e1ffb743e57945c8af68ac2d35bed05f6d3c8ec967fe263ac808b645ab56c39ebad3699280720c47f63ec87bbeef5
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -7,19 +7,20 @@ Apple script forked from: [dronir/SpotifyControl](https://github.com/dronir/Spot
|
|
7
7
|
## Command-line options
|
8
8
|
|
9
9
|
```
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
-
|
21
|
-
-
|
22
|
-
-
|
10
|
+
spotify_osx_controller [options] play [--track=<name>][--artist=<name>][--album=<name>] Start playback
|
11
|
+
spotify_osx_controller [options] play-pause Play/pause playback
|
12
|
+
spotify_osx_controller [options] stop Stop playback
|
13
|
+
spotify_osx_controller [options] next Play next track
|
14
|
+
spotify_osx_controller [options] previous Play previous track
|
15
|
+
spotify_osx_controller [options] jump [--seconds=<seconds>] Jump to <seconds> of current track
|
16
|
+
spotify_osx_controller [options] forward [--seconds=<seconds>] Jump <seconds> ahead
|
17
|
+
spotify_osx_controller [options] rewind [--seconds=<seconds>] Rewind <seconds> backwards
|
18
|
+
|
19
|
+
Where available [options] are the following:
|
20
|
+
-v, --volume=<i> Set playback volume to <i>, where <i> is number between 0 and 100
|
21
|
+
-S, --shuffle Toggle shuffle
|
22
|
+
-R, --repeat Toggle repeat
|
23
|
+
-i, --info Display information about the current track
|
23
24
|
```
|
24
25
|
|
25
26
|
## Installation
|
data/bin/spotify_osx_controller
CHANGED
@@ -3,56 +3,94 @@ require "spotify_osx_controller"
|
|
3
3
|
require "trollop"
|
4
4
|
|
5
5
|
|
6
|
+
SUB_COMMANDS = %w(play play-pause stop next previous jump forward rewind)
|
6
7
|
opts = Trollop::options do
|
7
|
-
|
8
|
-
OSX CLI for Spotify
|
8
|
+
banner <<-EOS
|
9
|
+
OSX CLI for Spotify
|
9
10
|
|
10
11
|
Usage:
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
12
|
+
|
13
|
+
spotify_osx_controller [options] play [--track=<name>] [--artist=<name>] [--album=<name>] Start playback
|
14
|
+
spotify_osx_controller [options] play-pause Play/pause playback
|
15
|
+
spotify_osx_controller [options] stop Stop playback
|
16
|
+
spotify_osx_controller [options] next Play next track
|
17
|
+
spotify_osx_controller [options] previous Play previous track
|
18
|
+
spotify_osx_controller [options] jump [--seconds=<seconds>] Jump to <seconds> of current track
|
19
|
+
spotify_osx_controller [options] forward [--seconds=<seconds>] Jump <seconds> ahead
|
20
|
+
spotify_osx_controller [options] rewind [--seconds=<seconds>] Rewind <seconds> backwards
|
21
|
+
|
22
|
+
Where available [options] are the following:
|
23
|
+
|
24
|
+
EOS
|
25
|
+
|
24
26
|
opt :volume, 'Set playback volume to <i>, where <i> is number between 0 and 100', type: :integer
|
25
27
|
opt :shuffle, 'Toggle shuffle', type: :boolean, short: 'S'
|
26
28
|
opt :repeat, 'Toggle repeat', type: :boolean, short: 'R'
|
27
|
-
opt :info, 'Display information about the current track'
|
28
|
-
|
29
|
+
opt :info, 'Display information about the current track', type: :boolean, short: 'i'
|
30
|
+
stop_on SUB_COMMANDS
|
29
31
|
end
|
30
32
|
|
31
33
|
|
34
|
+
def global_cmds (opts)
|
35
|
+
if opts[:volume]
|
36
|
+
Trollop::die :volume, "must be between 0 and 100" if opts[:volume] < 0 or opts[:volume] > 100
|
37
|
+
SpotifyOsxController.volume opts[:volume]
|
38
|
+
end
|
39
|
+
if opts[:shuffle]
|
40
|
+
SpotifyOsxController.shuffle
|
41
|
+
end
|
42
|
+
if opts[:repeat]
|
43
|
+
SpotifyOsxController.repeat
|
44
|
+
end
|
45
|
+
if opts[:info]
|
46
|
+
SpotifyOsxController.info
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
32
50
|
|
33
|
-
|
34
|
-
|
35
|
-
|
51
|
+
cmd = ARGV.shift
|
52
|
+
case cmd
|
53
|
+
when "play"
|
54
|
+
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: []
|
58
|
+
end
|
59
|
+
SpotifyOsxController.play track: cmd_opts[:track], artist: cmd_opts[:artist], album: cmd_opts[:album]
|
60
|
+
when "play-pause"
|
36
61
|
SpotifyOsxController.play_pause
|
37
|
-
|
62
|
+
when "stop"
|
38
63
|
SpotifyOsxController.pause
|
39
|
-
|
64
|
+
when "next"
|
40
65
|
SpotifyOsxController.next
|
41
|
-
|
66
|
+
when "previous"
|
42
67
|
SpotifyOsxController.previous
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
SpotifyOsxController.
|
49
|
-
|
50
|
-
Trollop::
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
68
|
+
when "jump"
|
69
|
+
cmd_opts = Trollop::options do
|
70
|
+
opt :seconds, "Position in seconds to start play from", type: :integer, short: 's', required: true
|
71
|
+
end
|
72
|
+
Trollop::die :seconds, "must be greater that 0" if cmd_opts[:seconds] < 0
|
73
|
+
SpotifyOsxController.jump cmd_opts[:seconds]
|
74
|
+
when "forward"
|
75
|
+
cmd_opts = Trollop::options do
|
76
|
+
opt :seconds, "Number of seconds to jump ahead", type: :integer, short: 's', required: true
|
77
|
+
end
|
78
|
+
|
79
|
+
SpotifyOsxController.forward cmd_opts[:seconds]
|
80
|
+
when "rewind"
|
81
|
+
cmd_opts = Trollop::options do
|
82
|
+
opt :seconds, "Number of seconds to rewind", type: :integer, short: 's', required: true
|
83
|
+
end
|
84
|
+
|
85
|
+
SpotifyOsxController.rewind cmd_opts[:seconds]
|
86
|
+
|
87
|
+
when nil
|
88
|
+
global_cmds opts
|
89
|
+
run_global = true
|
90
|
+
else
|
91
|
+
Trollop::die "unknown subcommand #{cmd.inspect}"
|
58
92
|
end
|
93
|
+
|
94
|
+
global_cmds opts if !run_global
|
95
|
+
|
96
|
+
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require "rspotify"
|
2
|
+
|
3
|
+
module SpotifyOsxController
|
4
|
+
|
5
|
+
class Search
|
6
|
+
|
7
|
+
def initialize (parameters = {})
|
8
|
+
@track = parse parameters[:track]
|
9
|
+
@artist = parse parameters[:artist]
|
10
|
+
@album = parse parameters[:album]
|
11
|
+
@query = construct_query
|
12
|
+
@results = run_query
|
13
|
+
end
|
14
|
+
|
15
|
+
def any?
|
16
|
+
@results.any?
|
17
|
+
end
|
18
|
+
|
19
|
+
def first
|
20
|
+
@results.first
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def run_query ()
|
26
|
+
RSpotify::Track.search @query
|
27
|
+
end
|
28
|
+
|
29
|
+
def parse (array)
|
30
|
+
array.join('+') if array
|
31
|
+
end
|
32
|
+
|
33
|
+
def construct_query
|
34
|
+
query = ""
|
35
|
+
query += "artist:#{@artist} " if !@artist.empty?
|
36
|
+
query += "track:#{@track} " if !@track.empty?
|
37
|
+
query += "album:#{@album}" if !@album.empty?
|
38
|
+
query
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
end
|
@@ -1,9 +1,18 @@
|
|
1
1
|
require "spotify_osx_controller/version"
|
2
|
+
require "spotify_osx_controller/search.rb"
|
2
3
|
|
3
4
|
module SpotifyOsxController
|
4
|
-
|
5
|
-
|
6
|
-
|
5
|
+
|
6
|
+
def self.play(parameters = {})
|
7
|
+
if !parameters.values.all? &:empty?
|
8
|
+
search = Search.new(parameters)
|
9
|
+
|
10
|
+
if search.any?
|
11
|
+
uri = search.first.uri
|
12
|
+
buildScript "tell application \"Spotify\" to play track \"#{uri}\"\n"
|
13
|
+
else
|
14
|
+
puts "Error: no results"
|
15
|
+
end
|
7
16
|
else
|
8
17
|
buildScript "tell application \"Spotify\" to play\n"
|
9
18
|
end
|
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:
|
4
|
+
version: 2.0.0
|
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-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: trollop
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspotify
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -68,6 +82,7 @@ files:
|
|
68
82
|
- Rakefile
|
69
83
|
- bin/spotify_osx_controller
|
70
84
|
- lib/spotify_osx_controller.rb
|
85
|
+
- lib/spotify_osx_controller/search.rb
|
71
86
|
- lib/spotify_osx_controller/version.rb
|
72
87
|
- spotify_osx_controller.gemspec
|
73
88
|
homepage: https://github.com/DanielSwensson/SpotifyControl
|