spty 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/lib/spty/commands/base_command.rb +18 -6
- data/lib/spty/commands/help_command.rb +4 -5
- data/lib/spty/commands/info_command.rb +7 -7
- data/lib/spty/commands/launch_command.rb +2 -2
- data/lib/spty/commands/replay_command.rb +4 -4
- data/lib/spty/commands/skip_command.rb +5 -6
- data/lib/spty/commands/state_command.rb +5 -5
- data/lib/spty/commands/toggle_command.rb +5 -5
- data/lib/spty/commands/volume_command.rb +2 -2
- data/lib/spty/version.rb +1 -1
- metadata +2 -4
- data/lib/spty/commands/player_command.rb +0 -43
- data/lib/spty/commands/track_command.rb +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03f320416e178aac141deb66fcb50a15c0855920
|
4
|
+
data.tar.gz: 612e24b134d748dfe3b1a96068dc10bdefcea377
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03da0ee0f8774e25bc36fb6fb8a37bbff58c7ffa3a9f7c5c089f1a509088e4c3c67aa4432b596f2a697dbaf70e930ae21aac8075b7582b2e33f65be228cfd11c
|
7
|
+
data.tar.gz: cd384ef7c3c4612f87fdd0fce4dd4f4c73e58814ed8a743f7344f3f19cd58eaccea0d63a87a60b53829c37cb65cc6445c14d63cd8f785f496df9e8ee315054ad
|
data/README.md
CHANGED
@@ -22,27 +22,27 @@ $ spty version
|
|
22
22
|
|
23
23
|
Show current player state
|
24
24
|
```
|
25
|
-
$ spty
|
25
|
+
$ spty state
|
26
26
|
```
|
27
27
|
|
28
28
|
Toggle player play / pause
|
29
29
|
```
|
30
|
-
$ spty
|
30
|
+
$ spty toggle
|
31
31
|
```
|
32
32
|
|
33
33
|
Get track title and artist
|
34
34
|
```
|
35
|
-
$ spty
|
35
|
+
$ spty info
|
36
36
|
```
|
37
37
|
|
38
38
|
Skip track and play the next track
|
39
39
|
```
|
40
|
-
$ spty
|
40
|
+
$ spty skip
|
41
41
|
```
|
42
42
|
|
43
43
|
Replay previous track
|
44
44
|
```
|
45
|
-
$ spty
|
45
|
+
$ spty replay
|
46
46
|
```
|
47
47
|
|
48
48
|
Show current volume level
|
@@ -1,13 +1,25 @@
|
|
1
1
|
module Spty::Command
|
2
2
|
class BaseCommand
|
3
|
-
|
4
|
-
|
3
|
+
# Check if the application is running
|
4
|
+
ASCRIPT_PLAYER_DETECT = <<-EOL
|
5
|
+
if application "Spotify" is running then
|
6
|
+
return "Running"
|
7
|
+
else
|
8
|
+
return "Not running"
|
9
|
+
end if
|
10
|
+
EOL
|
11
|
+
def self.running?(show_mesg: true)
|
12
|
+
player_running = Spty::AppleScriptRunner.(ASCRIPT_PLAYER_DETECT)
|
13
|
+
return true if player_running.strip == 'Running'
|
5
14
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
15
|
+
if show_mesg
|
16
|
+
output = "player not running\n"\
|
17
|
+
"to launch Spotify player, use: spty launch"
|
18
|
+
|
19
|
+
puts output
|
10
20
|
end
|
21
|
+
|
22
|
+
false
|
11
23
|
end
|
12
24
|
end
|
13
25
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
module Spty::Command
|
2
2
|
class HelpCommand
|
3
|
-
|
4
3
|
HELP_TEXT =
|
5
4
|
"usage: spty <command> [<args>]\n"\
|
6
5
|
"\n"\
|
@@ -9,10 +8,10 @@ module Spty::Command
|
|
9
8
|
" toggle Toggle player play or pause\n"\
|
10
9
|
" skip Skip the current track and play the next track\n"\
|
11
10
|
" replay Replay the current track\n"\
|
12
|
-
" volume Shows the current volume level"\
|
13
|
-
" volume up Increase the volume level by 10"\
|
14
|
-
" volume down Decrease the volume level by 11"\
|
15
|
-
" volume [number] Set the volume level to number"\
|
11
|
+
" volume Shows the current volume level\n"\
|
12
|
+
" volume up Increase the volume level by 10\n"\
|
13
|
+
" volume down Decrease the volume level by 11\n"\
|
14
|
+
" volume [number] Set the volume level to number\n"\
|
16
15
|
"\n"\
|
17
16
|
"Track specific command\n"\
|
18
17
|
" info Show information for the current track\n"\
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Spty::Command
|
2
|
-
class InfoCommand
|
2
|
+
class InfoCommand < BaseCommand
|
3
3
|
ASCRIPT_TRACK_INFO = <<-EOL
|
4
4
|
tell application "Spotify"
|
5
5
|
set currentTrack to name of current track as string
|
@@ -9,13 +9,13 @@ module Spty::Command
|
|
9
9
|
end tell
|
10
10
|
EOL
|
11
11
|
def self.call(_, _command = 'info')
|
12
|
-
|
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)
|
12
|
+
return unless running?
|
16
13
|
|
17
|
-
|
18
|
-
|
14
|
+
track_info = Spty::AppleScriptRunner.(ASCRIPT_TRACK_INFO)
|
15
|
+
player_state_script = Spty::Command::StateCommand::ASCRIPT_PLAYER_STATE
|
16
|
+
player_state = Spty::AppleScriptRunner.(player_state_script)
|
17
|
+
|
18
|
+
puts "=> #{track_info.strip} [#{player_state.strip}]"
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module Spty::Command
|
2
|
-
class LaunchCommand
|
2
|
+
class LaunchCommand < BaseCommand
|
3
3
|
ASCRIPT_PLAYER_LAUNCH = <<-EOL
|
4
4
|
tell application "Spotify" to activate
|
5
5
|
EOL
|
6
6
|
|
7
7
|
def self.call(_, _command = 'launch')
|
8
|
-
if
|
8
|
+
if running?(show_mesg: false)
|
9
9
|
puts 'Spotify player is running'
|
10
10
|
return
|
11
11
|
end
|
@@ -7,10 +7,10 @@ module Spty::Command
|
|
7
7
|
end tell
|
8
8
|
EOL
|
9
9
|
def self.call(_, command = 'replay')
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
return unless running?
|
11
|
+
|
12
|
+
Spty::AppleScriptRunner.(ASCRIPT_TRACK_REPLAY)
|
13
|
+
Spty::Command::InfoCommand.(nil, command)
|
14
14
|
end
|
15
15
|
|
16
16
|
end
|
@@ -1,16 +1,15 @@
|
|
1
1
|
module Spty::Command
|
2
|
-
class SkipCommand
|
3
|
-
|
2
|
+
class SkipCommand < BaseCommand
|
4
3
|
ASCRIPT_TRACK_SKIP = <<-EOL
|
5
4
|
tell application "Spotify"
|
6
5
|
next track
|
7
6
|
end tell
|
8
7
|
EOL
|
9
8
|
def self.call(_, command = 'skip')
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
return unless running?
|
10
|
+
|
11
|
+
Spty::AppleScriptRunner.(ASCRIPT_TRACK_SKIP)
|
12
|
+
Spty::Command::InfoCommand.(nil, command)
|
14
13
|
end
|
15
14
|
|
16
15
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
module Spty::Command
|
2
|
-
class StateCommand
|
2
|
+
class StateCommand < BaseCommand
|
3
3
|
# Display the current state of the player.
|
4
4
|
ASCRIPT_PLAYER_STATE = <<-EOL
|
5
5
|
tell application "Spotify" to return player state
|
6
6
|
EOL
|
7
7
|
def self.call(_, _command = nil)
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
return unless running?
|
9
|
+
|
10
|
+
player_state = Spty::AppleScriptRunner.(ASCRIPT_PLAYER_STATE)
|
11
|
+
puts "=> player #{player_state}"
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
module Spty::Command
|
2
|
-
class ToggleCommand
|
2
|
+
class ToggleCommand < BaseCommand
|
3
3
|
# Toggle player play / pause
|
4
4
|
ASCRIPT_PLAYER_TOGGLE = <<-EOL
|
5
5
|
tell application "Spotify" to playpause
|
6
6
|
EOL
|
7
7
|
def self.call(_, command = 'toggle')
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
return unless running?
|
9
|
+
|
10
|
+
Spty::AppleScriptRunner.(ASCRIPT_PLAYER_TOGGLE)
|
11
|
+
Spty::Command::StateCommand.(nil, command)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
data/lib/spty/version.rb
CHANGED
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.5.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-09-
|
11
|
+
date: 2017-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -107,12 +107,10 @@ files:
|
|
107
107
|
- lib/spty/commands/help_command.rb
|
108
108
|
- lib/spty/commands/info_command.rb
|
109
109
|
- lib/spty/commands/launch_command.rb
|
110
|
-
- lib/spty/commands/player_command.rb
|
111
110
|
- lib/spty/commands/replay_command.rb
|
112
111
|
- lib/spty/commands/skip_command.rb
|
113
112
|
- lib/spty/commands/state_command.rb
|
114
113
|
- lib/spty/commands/toggle_command.rb
|
115
|
-
- lib/spty/commands/track_command.rb
|
116
114
|
- lib/spty/commands/version_command.rb
|
117
115
|
- lib/spty/commands/volume_command.rb
|
118
116
|
- lib/spty/version.rb
|
@@ -1,43 +0,0 @@
|
|
1
|
-
module Spty::Command
|
2
|
-
class PlayerCommand < BaseCommand
|
3
|
-
# Check if the application is running
|
4
|
-
ASCRIPT_PLAYER_DETECT = <<-EOL
|
5
|
-
if application "Spotify" is running then
|
6
|
-
return "Running"
|
7
|
-
else
|
8
|
-
return "Not running"
|
9
|
-
end if
|
10
|
-
EOL
|
11
|
-
def self.running?(show_mesg: true)
|
12
|
-
player_running = Spty::AppleScriptRunner.(ASCRIPT_PLAYER_DETECT)
|
13
|
-
return true if player_running.strip == 'Running'
|
14
|
-
|
15
|
-
if show_mesg
|
16
|
-
output = "player not running\n"\
|
17
|
-
"to launch Spotify player, use: spty launch"
|
18
|
-
|
19
|
-
puts output
|
20
|
-
end
|
21
|
-
|
22
|
-
false
|
23
|
-
end
|
24
|
-
|
25
|
-
# Method is depreciated. It calls the actuall method
|
26
|
-
# This method should be removed on next release
|
27
|
-
def self.state(_, command = 'state')
|
28
|
-
if running?
|
29
|
-
Spty::Command::StateCommand.('state')
|
30
|
-
puts "Command is deprecated. Use \"spty #{command}\"."
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
# Method is depreciated. It calls the actuall method
|
35
|
-
# This method should be removed on next release
|
36
|
-
def self.toggle(_, command = 'toggle')
|
37
|
-
if running?
|
38
|
-
Spty::Command::ToggleCommand.(nil, 'toggle')
|
39
|
-
puts "Command is deprecated. Use \"spty #{command}\"."
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module Spty::Command
|
2
|
-
class TrackCommand < BaseCommand
|
3
|
-
|
4
|
-
# This command is deprecated.
|
5
|
-
def self.info(_, command = 'info')
|
6
|
-
if Spty::Command::PlayerCommand.running?
|
7
|
-
Spty::Command::InfoCommand.(nil, 'info')
|
8
|
-
puts "Command is deprecated. Use \"spty #{command}\"."
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
# This command is deprecated.
|
13
|
-
def self.skip(_)
|
14
|
-
Spty::Command::SkipCommand.call(nil)
|
15
|
-
puts 'Command is deprecated. Use "spty skip".'
|
16
|
-
end
|
17
|
-
|
18
|
-
# This command is deprecared.
|
19
|
-
def self.replay(_)
|
20
|
-
#move_track(ASCRIPT_TRACK_REPLAY, 'replay')
|
21
|
-
Spty::Command::ReplayCommand.call(nil)
|
22
|
-
puts 'Command is deprecated. Use "spty replay".'
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
end
|