muzak 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +1 -1
- data/README.md +1 -13
- data/bin/muzak-cmd +2 -1
- data/bin/muzakd +10 -12
- data/lib/muzak/cmd.rb +2 -0
- data/lib/muzak/cmd/config.rb +1 -1
- data/lib/muzak/cmd/meta.rb +15 -5
- data/lib/muzak/cmd/player.rb +8 -5
- data/lib/muzak/const.rb +1 -1
- data/lib/muzak/player/mpv.rb +8 -12
- 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: faf36636905a8835a68aaa8ec30165784542ee9f
|
4
|
+
data.tar.gz: a70897b4fb5b8531bb218345e7d10c535e9e1531
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: afb580f66f98918d8cf11f2732e5b73614288c8f1a3b189b73280d0410b993665b518837f40f3c5624ae3a4442027664b8d8d3faf254581203a8425469ddc396
|
7
|
+
data.tar.gz: 7380f4e9d0433443acbf791e5b99461d597a9a57900ea4cb9bfd471db5c4c61c51f5e7da86bd1d71dd0db6691de9a26afaf27461b797367f348e5ded00164702
|
data/.yardopts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
--tag command:"muzak command" --tag cmdexample:"example invocation" --no-private --markup-provider=redcarpet --markup=markdown - README.md LICENSE
|
1
|
+
--tag command:"muzak command" --tag cmdexample:"example invocation" --no-private --markup-provider=redcarpet --markup=markdown - README.md COMMANDS.md LICENSE
|
data/README.md
CHANGED
@@ -15,19 +15,9 @@ and the state of the player.
|
|
15
15
|
|
16
16
|
Muzak is still a work in process. Don't expect stability or pleasant output.
|
17
17
|
|
18
|
-
On the command-line:
|
19
|
-
|
20
|
-
```shell
|
21
|
-
$ ruby -Ilib bin/muzak.rb
|
22
|
-
muzak> help
|
23
|
-
```
|
24
|
-
|
25
|
-
Daemonized:
|
26
|
-
|
27
18
|
```shell
|
28
19
|
$ ruby -Ilib bin/muzakd.rb
|
29
|
-
$
|
30
|
-
$ ruby -Ilib bin/muzak-cmd "command"
|
20
|
+
$ ruby -Ilib bin/muzak-cmd enqueue-artist "The Beatles"
|
31
21
|
```
|
32
22
|
|
33
23
|
### TODO
|
@@ -35,5 +25,3 @@ $ ruby -Ilib bin/muzak-cmd "command"
|
|
35
25
|
* GUI "frontend"?
|
36
26
|
* isolation of art and music output (`Muzak::ArtProvider`?)
|
37
27
|
* current indexing/sorting logic is terrible
|
38
|
-
* all the documentation
|
39
|
-
* readline's tab complete is terrible with spaces (maybe use `bond`?)
|
data/bin/muzak-cmd
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require "muzak"
|
4
4
|
require "socket"
|
5
5
|
require "json"
|
6
|
+
require "shellwords"
|
6
7
|
|
7
8
|
begin
|
8
9
|
server_host = Muzak::Config.daemon_host
|
@@ -14,6 +15,6 @@ rescue
|
|
14
15
|
exit 1
|
15
16
|
end
|
16
17
|
|
17
|
-
sock.puts
|
18
|
+
sock.puts Shellwords.shelljoin ARGV
|
18
19
|
puts sock.gets
|
19
20
|
sock.close
|
data/bin/muzakd
CHANGED
@@ -14,18 +14,16 @@ muzak = Muzak::Instance.new
|
|
14
14
|
server_port = Muzak::Config.daemon_port || 2669
|
15
15
|
server = TCPServer.new server_port
|
16
16
|
|
17
|
-
exiting = false
|
18
|
-
|
19
17
|
loop do
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
18
|
+
Thread.new(server.accept) do |client|
|
19
|
+
begin
|
20
|
+
cmd_argv = Shellwords.split(client.readline)
|
21
|
+
client.puts(muzak.command(*cmd_argv).to_json)
|
22
|
+
exit! 0 if cmd_argv.first == "quit"
|
23
|
+
rescue Exception => e
|
24
|
+
client.puts({ response: { error: e.to_s } }.to_json)
|
25
|
+
ensure
|
26
|
+
client.close if client
|
27
|
+
end
|
30
28
|
end
|
31
29
|
end
|
data/lib/muzak/cmd.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
Dir.glob(File.join(__dir__, "cmd/*")) { |f| require_relative f }
|
2
2
|
|
3
3
|
module Muzak
|
4
|
+
# The namespace for all commands exposed by muzak.
|
5
|
+
# @see file:COMMANDS.md User Commands
|
4
6
|
module Cmd
|
5
7
|
# load commands included by the user
|
6
8
|
Dir.glob(File.join(USER_COMMAND_DIR, "*")) { |file| require file }
|
data/lib/muzak/cmd/config.rb
CHANGED
data/lib/muzak/cmd/meta.rb
CHANGED
@@ -1,13 +1,23 @@
|
|
1
1
|
module Muzak
|
2
2
|
module Cmd
|
3
|
-
#
|
3
|
+
# Return a simple heartbeat message.
|
4
|
+
# @command `ping`
|
5
|
+
# @cmdexample `muzak> ping`
|
6
|
+
def ping
|
7
|
+
timestamp = Time.now.to_i
|
8
|
+
debug "pong: #{timestamp}"
|
9
|
+
|
10
|
+
build_response data: {
|
11
|
+
pong: timestamp
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
# Return a "helpful" listing of commands.
|
4
16
|
# @command `help`
|
5
17
|
# @cmdexample `muzak> help`
|
6
18
|
def help(*args)
|
7
|
-
commands = Muzak::Cmd.commands.join(", ")
|
8
|
-
|
9
19
|
build_response data: {
|
10
|
-
commands: commands
|
20
|
+
commands: Muzak::Cmd.commands
|
11
21
|
}
|
12
22
|
end
|
13
23
|
|
@@ -29,7 +39,7 @@ module Muzak
|
|
29
39
|
verbose "muzak is quitting..."
|
30
40
|
player.deactivate!
|
31
41
|
|
32
|
-
build_response
|
42
|
+
build_response data: "quitting"
|
33
43
|
end
|
34
44
|
end
|
35
45
|
end
|
data/lib/muzak/cmd/player.rb
CHANGED
@@ -7,12 +7,13 @@ module Muzak
|
|
7
7
|
def player_activate
|
8
8
|
if player.running?
|
9
9
|
warn "player is already running"
|
10
|
-
|
10
|
+
else
|
11
|
+
player.activate!
|
11
12
|
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
build_response data: {
|
15
|
+
player: player.class.name
|
16
|
+
}
|
16
17
|
end
|
17
18
|
|
18
19
|
# Deactivate the configured player.
|
@@ -25,7 +26,9 @@ module Muzak
|
|
25
26
|
# do cleanup even if the player isn't running, just in case
|
26
27
|
player.deactivate!
|
27
28
|
|
28
|
-
build_response
|
29
|
+
build_response data: {
|
30
|
+
player: player.class.name
|
31
|
+
}
|
29
32
|
end
|
30
33
|
|
31
34
|
# Tell the player to begin playback.
|
data/lib/muzak/const.rb
CHANGED
data/lib/muzak/player/mpv.rb
CHANGED
@@ -161,6 +161,9 @@ module Muzak
|
|
161
161
|
playlist = []
|
162
162
|
|
163
163
|
entries.times do |i|
|
164
|
+
# TODO: this is slow and should be avoided at all costs,
|
165
|
+
# since we have access to these Song instances earlier
|
166
|
+
# in the object's lifecycle.
|
164
167
|
playlist << Song.new(get_property("playlist/#{i}/filename"))
|
165
168
|
end
|
166
169
|
|
@@ -184,11 +187,11 @@ module Muzak
|
|
184
187
|
end
|
185
188
|
|
186
189
|
# Get mpv's currently playing song.
|
187
|
-
# @return [Song] the currently playing song
|
190
|
+
# @return [Song, nil] the currently playing song
|
188
191
|
def now_playing
|
189
|
-
return unless
|
192
|
+
return unless playing?
|
190
193
|
|
191
|
-
Song.new(get_property "path")
|
194
|
+
@_now_playing ||= Song.new(get_property "path")
|
192
195
|
end
|
193
196
|
|
194
197
|
private
|
@@ -232,17 +235,10 @@ module Muzak
|
|
232
235
|
Thread.new do
|
233
236
|
case event
|
234
237
|
when "file-loaded"
|
235
|
-
|
236
|
-
# to Song objects earlier in the object's lifetime.
|
237
|
-
# the "correct" way to do this would be to sync an external
|
238
|
-
# playlist with mpv's internal one and access that instead
|
239
|
-
# of re-creating the Song from mpv properties.
|
240
|
-
# another idea: serialize Song objects into mpv's properties
|
241
|
-
# somehow.
|
242
|
-
song = Song.new(get_property "path")
|
243
|
-
instance.event :song_loaded, song
|
238
|
+
instance.event :song_loaded, now_playing
|
244
239
|
when "end-file"
|
245
240
|
instance.event :song_unloaded
|
241
|
+
@_now_playing = nil
|
246
242
|
end
|
247
243
|
end
|
248
244
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: muzak
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Woodruff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: taglib-ruby
|