spty 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/spty/commands/info_command.rb +21 -0
- data/lib/spty/commands/player_command.rb +10 -14
- data/lib/spty/commands/replay_command.rb +17 -0
- data/lib/spty/commands/skip_command.rb +17 -0
- data/lib/spty/commands/state_command.rb +14 -0
- data/lib/spty/commands/toggle_command.rb +14 -0
- data/lib/spty/commands/track_command.rb +11 -33
- data/lib/spty/version.rb +1 -1
- data/spty.gemspec +2 -2
- metadata +9 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36a4a7466d3e6d655f2738738476d2411d604e12
|
4
|
+
data.tar.gz: f16da74414643bf5380ddd217e81975878cebbd5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 833a1aac1594c88ff35ea7ae3c7e08bf93244537975a1686f1b5473efc89f92cb8c642b7a654ce1b7281cebc017fccdbf1109d60b32bf18357792b04f4e60226
|
7
|
+
data.tar.gz: 9410b8bcb475f9904c712e506df2bb39bd334d8c68ea2c37cf15b127dbbefd4b16b152ef3312d1d263ca98574b96ddc0fb5a3e96c7ce1163f081264332a60f03
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Spty::Command
|
2
|
+
class InfoCommand
|
3
|
+
ASCRIPT_TRACK_INFO = <<-EOL
|
4
|
+
tell application "Spotify"
|
5
|
+
set currentTrack to name of current track as string
|
6
|
+
set currentArtist to artist of current track as string
|
7
|
+
|
8
|
+
return currentTrack & " - " & currentArtist
|
9
|
+
end tell
|
10
|
+
EOL
|
11
|
+
def self.call(_, _command = 'info')
|
12
|
+
if Spty::Command::PlayerCommand.running?
|
13
|
+
track_info = Spty::AppleScriptRunner.(ASCRIPT_TRACK_INFO)
|
14
|
+
player_state_script = Spty::Command::StateCommand::ASCRIPT_PLAYER_STATE
|
15
|
+
player_state = Spty::AppleScriptRunner.(player_state_script)
|
16
|
+
|
17
|
+
puts "=> #{track_info.strip} [#{player_state.strip}]"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -15,25 +15,21 @@ module Spty::Command
|
|
15
15
|
puts "=> player not running" and return false
|
16
16
|
end
|
17
17
|
|
18
|
-
#
|
19
|
-
|
20
|
-
|
21
|
-
EOL
|
22
|
-
def self.state(_)
|
18
|
+
# Method is depreciated. It calls the actuall method
|
19
|
+
# This method should be removed on next release
|
20
|
+
def self.state(_, command = 'state')
|
23
21
|
if running?
|
24
|
-
|
25
|
-
puts "
|
22
|
+
Spty::Command::StateCommand.('state')
|
23
|
+
puts "Command is deprecated. Use \"spty #{command}\"."
|
26
24
|
end
|
27
25
|
end
|
28
26
|
|
29
|
-
#
|
30
|
-
|
31
|
-
|
32
|
-
EOL
|
33
|
-
def self.toggle(_)
|
27
|
+
# Method is depreciated. It calls the actuall method
|
28
|
+
# This method should be removed on next release
|
29
|
+
def self.toggle(_, command = 'toggle')
|
34
30
|
if running?
|
35
|
-
Spty::
|
36
|
-
|
31
|
+
Spty::Command::ToggleCommand.(nil, 'toggle')
|
32
|
+
puts "Command is deprecated. Use \"spty #{command}\"."
|
37
33
|
end
|
38
34
|
end
|
39
35
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Spty::Command
|
2
|
+
class ReplayCommand < BaseCommand
|
3
|
+
|
4
|
+
ASCRIPT_TRACK_REPLAY = <<-EOL
|
5
|
+
tell application "Spotify"
|
6
|
+
previous track
|
7
|
+
end tell
|
8
|
+
EOL
|
9
|
+
def self.call(_, command = 'replay')
|
10
|
+
if Spty::Command::PlayerCommand.running?
|
11
|
+
Spty::AppleScriptRunner.(ASCRIPT_TRACK_REPLAY)
|
12
|
+
Spty::Command::InfoCommand.(nil, command)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Spty::Command
|
2
|
+
class SkipCommand
|
3
|
+
|
4
|
+
ASCRIPT_TRACK_SKIP = <<-EOL
|
5
|
+
tell application "Spotify"
|
6
|
+
next track
|
7
|
+
end tell
|
8
|
+
EOL
|
9
|
+
def self.call(_, command = 'skip')
|
10
|
+
if Spty::Command::PlayerCommand.running?
|
11
|
+
Spty::AppleScriptRunner.(ASCRIPT_TRACK_SKIP)
|
12
|
+
Spty::Command::InfoCommand.(nil, command)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Spty::Command
|
2
|
+
class StateCommand
|
3
|
+
# Display the current state of the player.
|
4
|
+
ASCRIPT_PLAYER_STATE = <<-EOL
|
5
|
+
tell application "Spotify" to return player state
|
6
|
+
EOL
|
7
|
+
def self.call(_, _command = nil)
|
8
|
+
if Spty::Command::PlayerCommand.running?
|
9
|
+
player_state = Spty::AppleScriptRunner.(ASCRIPT_PLAYER_STATE)
|
10
|
+
puts "=> player #{player_state}"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Spty::Command
|
2
|
+
class ToggleCommand
|
3
|
+
# Toggle player play / pause
|
4
|
+
ASCRIPT_PLAYER_TOGGLE = <<-EOL
|
5
|
+
tell application "Spotify" to playpause
|
6
|
+
EOL
|
7
|
+
def self.call(_, command = 'toggle')
|
8
|
+
if Spty::Command::PlayerCommand.running?
|
9
|
+
Spty::AppleScriptRunner.(ASCRIPT_PLAYER_TOGGLE)
|
10
|
+
Spty::Command::StateCommand.(nil, command)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -1,48 +1,26 @@
|
|
1
1
|
module Spty::Command
|
2
2
|
class TrackCommand < BaseCommand
|
3
|
-
ASCRIPT_TRACK_INFO = <<-EOL
|
4
|
-
tell application "Spotify"
|
5
|
-
set currentTrack to name of current track as string
|
6
|
-
set currentArtist to artist of current track as string
|
7
3
|
|
8
|
-
|
9
|
-
|
10
|
-
EOL
|
11
|
-
def self.info(_)
|
4
|
+
# This command is deprecated.
|
5
|
+
def self.info(_, command = 'info')
|
12
6
|
if Spty::Command::PlayerCommand.running?
|
13
|
-
|
14
|
-
|
15
|
-
player_state = Spty::AppleScriptRunner.(player_state_script)
|
16
|
-
|
17
|
-
puts "=> #{track_info.strip} [#{player_state.strip}]"
|
7
|
+
Spty::Command::InfoCommand.(nil, 'info')
|
8
|
+
puts "Command is deprecated. Use \"spty #{command}\"."
|
18
9
|
end
|
19
10
|
end
|
20
11
|
|
21
|
-
|
22
|
-
tell application "Spotify"
|
23
|
-
next track
|
24
|
-
end tell
|
25
|
-
EOL
|
12
|
+
# This command is deprecated.
|
26
13
|
def self.skip(_)
|
27
|
-
|
14
|
+
Spty::Command::SkipCommand.call(nil)
|
15
|
+
puts 'Command is deprecated. Use "spty skip".'
|
28
16
|
end
|
29
17
|
|
30
|
-
|
31
|
-
tell application "Spotify"
|
32
|
-
previous track
|
33
|
-
end tell
|
34
|
-
EOL
|
18
|
+
# This command is deprecared.
|
35
19
|
def self.replay(_)
|
36
|
-
move_track(ASCRIPT_TRACK_REPLAY)
|
37
|
-
|
38
|
-
|
39
|
-
def self.move_track(ascript)
|
40
|
-
if Spty::Command::PlayerCommand.running?
|
41
|
-
Spty::AppleScriptRunner.(ascript)
|
42
|
-
Spty::Command::TrackCommand.info(nil)
|
43
|
-
end
|
20
|
+
#move_track(ASCRIPT_TRACK_REPLAY, 'replay')
|
21
|
+
Spty::Command::ReplayCommand.call(nil)
|
22
|
+
puts 'Command is deprecated. Use "spty replay".'
|
44
23
|
end
|
45
24
|
|
46
|
-
private_class_method :move_track
|
47
25
|
end
|
48
26
|
end
|
data/lib/spty/version.rb
CHANGED
data/spty.gemspec
CHANGED
@@ -10,8 +10,8 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["jibone@gmail.com"]
|
11
11
|
|
12
12
|
spec.summary = %q{Spotify Player Terminal Utility}
|
13
|
-
spec.description =
|
14
|
-
|
13
|
+
spec.description = "Control your Spotify player from the terminal. "\
|
14
|
+
"Currently only works for Mac OSX."
|
15
15
|
spec.homepage = "https://github.com/jibone/spty-rb"
|
16
16
|
spec.license = "MIT"
|
17
17
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- J Shamsul
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,9 +66,8 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '9.0'
|
69
|
-
description:
|
70
|
-
|
71
|
-
Currently only works for Mac OSX.
|
69
|
+
description: Control your Spotify player from the terminal. Currently only works for
|
70
|
+
Mac OSX.
|
72
71
|
email:
|
73
72
|
- jibone@gmail.com
|
74
73
|
executables:
|
@@ -91,7 +90,12 @@ files:
|
|
91
90
|
- lib/spty/apple_script_runner.rb
|
92
91
|
- lib/spty/cli.rb
|
93
92
|
- lib/spty/commands/base_command.rb
|
93
|
+
- lib/spty/commands/info_command.rb
|
94
94
|
- lib/spty/commands/player_command.rb
|
95
|
+
- lib/spty/commands/replay_command.rb
|
96
|
+
- lib/spty/commands/skip_command.rb
|
97
|
+
- lib/spty/commands/state_command.rb
|
98
|
+
- lib/spty/commands/toggle_command.rb
|
95
99
|
- lib/spty/commands/track_command.rb
|
96
100
|
- lib/spty/commands/version_command.rb
|
97
101
|
- lib/spty/version.rb
|