muzak 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/bin/muzak-dmenu +2 -1
- data/lib/muzak.rb +1 -0
- data/lib/muzak/cmd.rb +1 -9
- data/lib/muzak/cmd/config.rb +1 -41
- data/lib/muzak/cmd/index.rb +4 -4
- data/lib/muzak/cmd/player.rb +1 -1
- data/lib/muzak/config.rb +34 -0
- data/lib/muzak/const.rb +1 -1
- data/lib/muzak/index.rb +4 -0
- data/lib/muzak/instance.rb +5 -8
- data/lib/muzak/player/mpv.rb +1 -1
- data/lib/muzak/plugin/cava.rb +1 -1
- data/lib/muzak/plugin/scrobble.rb +1 -1
- data/lib/muzak/utils.rb +8 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2004a69f30d2467efb106868ca1882dcc8adcd1c
|
4
|
+
data.tar.gz: a2af36014644a54b49d3756ca0cf7823442dbea1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61fff1242efdd7eccd57a999352c2a58a41cad230b7b29e65bac2cdd8560aae6494dd22078ff9cdb3129aab4b45ad4d241f3f3ae3234a3aa5cbc7fecf933f803
|
7
|
+
data.tar.gz: de3071c222e36d73e08bdb7f8119552ac92828ffaa90a5d92d8709d60cb3495411e62fb6763327b1fce73f2c483d72e750cc1e9800ff2b5f2268d5c9f44584e2
|
data/README.md
CHANGED
data/bin/muzak-dmenu
CHANGED
data/lib/muzak.rb
CHANGED
data/lib/muzak/cmd.rb
CHANGED
@@ -5,17 +5,9 @@ module Muzak
|
|
5
5
|
# load commands included by the user
|
6
6
|
Dir.glob(File.join(USER_COMMAND_DIR, "*")) { |file| require file }
|
7
7
|
|
8
|
-
def self.resolve_command(cmd)
|
9
|
-
cmd.tr "-", "_"
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.resolve_method(meth)
|
13
|
-
meth.to_s.tr "_", "-"
|
14
|
-
end
|
15
|
-
|
16
8
|
def self.commands
|
17
9
|
commands = instance_methods.map(&:to_s).reject { |m| m.start_with?("_") }
|
18
|
-
commands.map { |c|
|
10
|
+
commands.map { |c| Utils.resolve_method c }
|
19
11
|
end
|
20
12
|
end
|
21
13
|
end
|
data/lib/muzak/cmd/config.rb
CHANGED
@@ -2,52 +2,12 @@ require "yaml"
|
|
2
2
|
|
3
3
|
module Muzak
|
4
4
|
module Cmd
|
5
|
-
def _config_available?
|
6
|
-
File.file?(CONFIG_FILE)
|
7
|
-
end
|
8
|
-
|
9
|
-
def _config_loaded?
|
10
|
-
!!@config
|
11
|
-
end
|
12
|
-
|
13
|
-
def _config_sync
|
14
|
-
debug "syncing config hash with #{CONFIG_FILE}"
|
15
|
-
File.open(CONFIG_FILE, "w") { |io| io.write @config.to_yaml }
|
16
|
-
end
|
17
|
-
|
18
|
-
def _config_init
|
19
|
-
debug "creating a config file in #{CONFIG_FILE}"
|
20
|
-
|
21
|
-
@config = {
|
22
|
-
"music" => File.expand_path("~/music"),
|
23
|
-
"player" => "mpv",
|
24
|
-
"index-autobuild" => 86400,
|
25
|
-
"deep-index" => false,
|
26
|
-
"jukebox-size" => 100
|
27
|
-
}
|
28
|
-
|
29
|
-
Dir.mkdir(CONFIG_DIR) unless Dir.exist?(CONFIG_DIR)
|
30
|
-
_config_sync
|
31
|
-
end
|
32
|
-
|
33
|
-
def _config_plugin?(name)
|
34
|
-
@config.key?("plugin-#{name}")
|
35
|
-
end
|
36
|
-
|
37
|
-
def config_load
|
38
|
-
verbose "loading config from #{CONFIG_FILE}"
|
39
|
-
|
40
|
-
@config = YAML::load_file(CONFIG_FILE)
|
41
|
-
end
|
42
|
-
|
43
5
|
def config_get(*args)
|
44
|
-
return unless _config_loaded?
|
45
|
-
|
46
6
|
fail_arity(args, 1)
|
47
7
|
key = args.shift
|
48
8
|
return if key.nil?
|
49
9
|
|
50
|
-
info "#{key}: #{
|
10
|
+
info "#{key}: #{Config.send Utils.resolve_method(key)}"
|
51
11
|
end
|
52
12
|
end
|
53
13
|
end
|
data/lib/muzak/cmd/index.rb
CHANGED
@@ -9,7 +9,7 @@ module Muzak
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def _index_outdated?
|
12
|
-
Time.now.to_i - @index
|
12
|
+
Time.now.to_i - @index.timestamp >= Config.index_autobuild
|
13
13
|
end
|
14
14
|
|
15
15
|
def _index_sync
|
@@ -22,9 +22,9 @@ module Muzak
|
|
22
22
|
|
23
23
|
@index = Index.load_index(INDEX_FILE)
|
24
24
|
|
25
|
-
# the order is important here, since
|
25
|
+
# the order is important here, since Config.index_autobuild
|
26
26
|
# will short-circuit if index-autobuild isn't set
|
27
|
-
if
|
27
|
+
if Config.index_autobuild && _index_outdated?
|
28
28
|
verbose "rebuilding outdated index"
|
29
29
|
index_build
|
30
30
|
end
|
@@ -35,7 +35,7 @@ module Muzak
|
|
35
35
|
|
36
36
|
verbose "building a new index, this may take a while"
|
37
37
|
|
38
|
-
@index = Index.new(
|
38
|
+
@index = Index.new(Config.music, deep: Config.deep_index)
|
39
39
|
_index_sync
|
40
40
|
end
|
41
41
|
|
data/lib/muzak/cmd/player.rb
CHANGED
data/lib/muzak/config.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require "yaml"
|
2
|
+
|
3
|
+
module Muzak
|
4
|
+
class Config
|
5
|
+
if File.exist?(CONFIG_FILE)
|
6
|
+
@config = YAML::load_file(CONFIG_FILE)
|
7
|
+
else
|
8
|
+
@config = {
|
9
|
+
"music" => File.expand_path("~/music"),
|
10
|
+
"player" => "mpv",
|
11
|
+
"index-autobuild" => 86400,
|
12
|
+
"deep-index" => false,
|
13
|
+
"jukebox-size" => 100
|
14
|
+
}
|
15
|
+
|
16
|
+
File.open(CONFIG_FILE, "w") { |io| io.write @config.to_yaml }
|
17
|
+
end
|
18
|
+
|
19
|
+
@config.each do |key, value|
|
20
|
+
define_singleton_method Utils.resolve_command(key) do
|
21
|
+
value
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# if a key doesn't exist, assume it's false
|
26
|
+
def self.method_missing(method, *args)
|
27
|
+
false
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.plugin?(pname)
|
31
|
+
respond_to? "plugin_#{pname}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/muzak/const.rb
CHANGED
data/lib/muzak/index.rb
CHANGED
data/lib/muzak/instance.rb
CHANGED
@@ -4,11 +4,11 @@ module Muzak
|
|
4
4
|
include Utils
|
5
5
|
|
6
6
|
def command(cmd, *args)
|
7
|
-
send
|
7
|
+
send Utils.resolve_command(cmd), *args
|
8
8
|
end
|
9
9
|
|
10
10
|
def method_missing(meth, *args)
|
11
|
-
warn "unknown command: #{
|
11
|
+
warn "unknown command: #{Utils.resolve_method(meth)}"
|
12
12
|
help
|
13
13
|
end
|
14
14
|
|
@@ -20,22 +20,19 @@ module Muzak
|
|
20
20
|
|
21
21
|
debug "muzak is starting..."
|
22
22
|
|
23
|
-
_config_init unless _config_available?
|
24
|
-
config_load
|
25
|
-
|
26
23
|
index_build unless _index_available?
|
27
24
|
index_load
|
28
25
|
|
29
|
-
@player = Player::PLAYER_MAP[
|
26
|
+
@player = Player::PLAYER_MAP[Config.player].new(self)
|
30
27
|
|
31
28
|
@plugins = initialize_plugins!
|
32
29
|
|
33
30
|
playlists_load
|
34
|
-
enqueue_playlist
|
31
|
+
enqueue_playlist Config.autoplay if Config.autoplay
|
35
32
|
end
|
36
33
|
|
37
34
|
def initialize_plugins!
|
38
|
-
pks = Plugin.plugin_classes.select { |pk|
|
35
|
+
pks = Plugin.plugin_classes.select { |pk| Config.plugin? pk.plugin_name }
|
39
36
|
pks.map { |pk| pk.new(self) }
|
40
37
|
end
|
41
38
|
|
data/lib/muzak/player/mpv.rb
CHANGED
@@ -35,7 +35,7 @@ module Muzak
|
|
35
35
|
"--input-ipc-server=%{socket}" % { socket: @sock_path }
|
36
36
|
]
|
37
37
|
|
38
|
-
mpv_args << "--geometry=#{
|
38
|
+
mpv_args << "--geometry=#{Config.art_geometry}" if Config.art_geometry
|
39
39
|
|
40
40
|
@pid = Process.spawn("mpv", *mpv_args)
|
41
41
|
|
data/lib/muzak/plugin/cava.rb
CHANGED
data/lib/muzak/utils.rb
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
module Muzak
|
2
2
|
module Utils
|
3
|
+
def self.resolve_command(cmd)
|
4
|
+
cmd.tr "-", "_"
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.resolve_method(meth)
|
8
|
+
meth.to_s.tr "_", "-"
|
9
|
+
end
|
10
|
+
|
3
11
|
def music?(filename)
|
4
12
|
[".mp3", ".flac", ".m4a", ".wav", ".ogg", ".oga", ".opus"].include?(File.extname(filename))
|
5
13
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: muzak
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Woodruff
|
@@ -48,6 +48,7 @@ files:
|
|
48
48
|
- lib/muzak/cmd/meta.rb
|
49
49
|
- lib/muzak/cmd/player.rb
|
50
50
|
- lib/muzak/cmd/playlist.rb
|
51
|
+
- lib/muzak/config.rb
|
51
52
|
- lib/muzak/const.rb
|
52
53
|
- lib/muzak/index.rb
|
53
54
|
- lib/muzak/instance.rb
|