muzak 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/muzak +0 -1
- data/bin/muzakd +0 -1
- data/lib/muzak/cmd/config.rb +1 -26
- data/lib/muzak/cmd/index.rb +11 -0
- data/lib/muzak/cmd/playlist.rb +3 -0
- data/lib/muzak/const.rb +5 -2
- data/lib/muzak/instance.rb +2 -2
- data/lib/muzak/plugin.rb +4 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e876cf1c3b780e3df5a034b8bd0b39929d29488
|
4
|
+
data.tar.gz: a07901cc1392f0da1a57b5dee944dc3c79cbc800
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: addec21a1b711fef4737b67a709b042bb9e5418414a9a540b8f28de953294b6758d0cb2fa25d71c65cc037e5fb67e9abe94581167c57cd702e7a16f7f7b18a32
|
7
|
+
data.tar.gz: 65d2e9edd5c2698f243bf92ff6d5b79ef6d963b4b4ef898dbc923a0f3fe092ab140740d307f7beddb8ae6e6bdc8be598d6f2ac3dd0c3aad0f0fa052a2a546221
|
data/bin/muzak
CHANGED
data/bin/muzakd
CHANGED
@@ -6,7 +6,6 @@ require "shellwords"
|
|
6
6
|
opts = {
|
7
7
|
debug: ARGV.include?("--debug") || ARGV.include?("-d"),
|
8
8
|
verbose: ARGV.include?("--verbose") || ARGV.include?("-v"),
|
9
|
-
batch: ARGV.include?("--batch") || ARGV.include?("-b")
|
10
9
|
}
|
11
10
|
|
12
11
|
Process.daemon unless opts[:debug] || opts[:verbose]
|
data/lib/muzak/cmd/config.rb
CHANGED
@@ -21,6 +21,7 @@ module Muzak
|
|
21
21
|
@config = {
|
22
22
|
"music" => File.expand_path("~/music"),
|
23
23
|
"player" => "mpv",
|
24
|
+
"index-autobuild" => 86400
|
24
25
|
}
|
25
26
|
|
26
27
|
Dir.mkdir(CONFIG_DIR) unless Dir.exist?(CONFIG_DIR)
|
@@ -37,32 +38,6 @@ module Muzak
|
|
37
38
|
@config = YAML::load_file(CONFIG_FILE)
|
38
39
|
end
|
39
40
|
|
40
|
-
def config_set(*args)
|
41
|
-
return unless _config_loaded?
|
42
|
-
|
43
|
-
fail_arity(args, 2)
|
44
|
-
key, value = args
|
45
|
-
return if key.nil? || value.nil?
|
46
|
-
|
47
|
-
debug "setting '#{key}' to '#{value}' in config"
|
48
|
-
|
49
|
-
@config[key] = value
|
50
|
-
_config_sync
|
51
|
-
end
|
52
|
-
|
53
|
-
def config_del(*args)
|
54
|
-
return unless _config_loaded?
|
55
|
-
|
56
|
-
fail_arity(args, 1)
|
57
|
-
key = args.shift
|
58
|
-
return if key.nil?
|
59
|
-
|
60
|
-
debug "removing '#{key}' from config"
|
61
|
-
|
62
|
-
@config.delete(key)
|
63
|
-
_config_sync
|
64
|
-
end
|
65
|
-
|
66
41
|
def config_get(*args)
|
67
42
|
return unless _config_loaded?
|
68
43
|
|
data/lib/muzak/cmd/index.rb
CHANGED
@@ -8,6 +8,10 @@ module Muzak
|
|
8
8
|
!!@index
|
9
9
|
end
|
10
10
|
|
11
|
+
def _index_outdated?
|
12
|
+
Time.now.to_i - @index["timestamp"] >= @config["index-autobuild"]
|
13
|
+
end
|
14
|
+
|
11
15
|
def _index_sync
|
12
16
|
debug "syncing index hash with #{INDEX_FILE}"
|
13
17
|
File.open(INDEX_FILE, "w") { |io| io.write @index.hash.to_yaml }
|
@@ -17,6 +21,13 @@ module Muzak
|
|
17
21
|
debug "loading index from #{INDEX_FILE}"
|
18
22
|
|
19
23
|
@index = Index.load_index(INDEX_FILE)
|
24
|
+
|
25
|
+
# the order is important here, since @config["index-autobuild"]
|
26
|
+
# will short-circuit if index-autobuild isn't set
|
27
|
+
if @config["index-autobuild"] && _index_outdated?
|
28
|
+
verbose "rebuilding outdated index"
|
29
|
+
index_build
|
30
|
+
end
|
20
31
|
end
|
21
32
|
|
22
33
|
def index_build(*args)
|
data/lib/muzak/cmd/playlist.rb
CHANGED
@@ -30,6 +30,8 @@ module Muzak
|
|
30
30
|
@playlist = Playlist.new(pname, [])
|
31
31
|
playlist_sync
|
32
32
|
end
|
33
|
+
|
34
|
+
event :playlist_loaded, @playlist
|
33
35
|
end
|
34
36
|
|
35
37
|
def playlist_delete(*args)
|
@@ -56,6 +58,7 @@ module Muzak
|
|
56
58
|
return unless _playlist_loaded?
|
57
59
|
|
58
60
|
@player.enqueue_playlist(@playlist)
|
61
|
+
event :playlist_enqueued, @playlist
|
59
62
|
end
|
60
63
|
|
61
64
|
def playlist_add_album(*args)
|
data/lib/muzak/const.rb
CHANGED
@@ -1,14 +1,17 @@
|
|
1
1
|
module Muzak
|
2
|
-
VERSION = "0.0.
|
2
|
+
VERSION = "0.0.2".freeze
|
3
3
|
|
4
4
|
CONFIG_DIR = File.expand_path("~/.config/muzak").freeze
|
5
5
|
CONFIG_FILE = File.join(CONFIG_DIR, "muzak.yml").freeze
|
6
6
|
INDEX_FILE = File.join(CONFIG_DIR, "index.yml").freeze
|
7
7
|
PLAYLIST_DIR = File.join(CONFIG_DIR, "playlists").freeze
|
8
|
+
USER_PLUGIN_DIR = File.join(CONFIG_DIR, "plugins").freeze
|
8
9
|
|
9
10
|
PLUGIN_EVENTS = [
|
10
11
|
:player_activated,
|
11
12
|
:player_deactivated,
|
12
|
-
:song_loaded
|
13
|
+
:song_loaded,
|
14
|
+
:playlist_loaded,
|
15
|
+
:playlist_enqueued
|
13
16
|
]
|
14
17
|
end
|
data/lib/muzak/instance.rb
CHANGED
@@ -24,9 +24,9 @@ module Muzak
|
|
24
24
|
|
25
25
|
@player = Player::PLAYER_MAP[@config["player"]].new(self)
|
26
26
|
|
27
|
-
playlist_load @config["default-playlist"] if @config["default-playlist"]
|
28
|
-
|
29
27
|
@plugins = initialize_plugins!
|
28
|
+
|
29
|
+
playlist_load @config["default-playlist"] if @config["default-playlist"]
|
30
30
|
end
|
31
31
|
|
32
32
|
def initialize_plugins!
|
data/lib/muzak/plugin.rb
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
# we have to require StubPlugin first because ruby's module resolution is bad
|
2
2
|
require_relative "plugin/stub_plugin"
|
3
3
|
|
4
|
+
# load plugins included with muzak
|
4
5
|
Dir.glob(File.join(__dir__, "plugin/*")) { |file| require_relative file }
|
5
6
|
|
6
7
|
module Muzak
|
7
8
|
module Plugin
|
9
|
+
# load plugins included by the user
|
10
|
+
Dir.glob(File.join(USER_PLUGIN_DIR, "*")) { |file| require file }
|
11
|
+
|
8
12
|
def self.plugin_classes
|
9
13
|
constants.map(&Plugin.method(:const_get)).grep(Class)
|
10
14
|
end
|