muzak 0.0.12 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/muzak/album.rb +1 -1
- data/lib/muzak/cmd/player.rb +0 -2
- data/lib/muzak/config.rb +18 -4
- data/lib/muzak/const.rb +1 -1
- data/lib/muzak/index.rb +17 -2
- data/lib/muzak/instance.rb +3 -1
- data/lib/muzak/utils.rb +8 -0
- 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: b6895336a3fa06db40e63f71d227e36b11a18397
|
4
|
+
data.tar.gz: 32f2ad6998993b76b783d9e97d8d91db55db1be0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bea81c7b13e504c158e9fb6d01beb3431d56b48c578b3f0c659dd059adad4c6cd87d1e3e975c58bf8be6fe1e412dad6508846cb5a98b603fa96a9948a3f0a4ed
|
7
|
+
data.tar.gz: 692b0d3ba74454f6c7669156f4cf472932c930bcb29e59399149371db188eaf01442062bd7a8be31af854bbc06f2636d2694505ab46edb1e9848c6e4ed7f78cb
|
data/lib/muzak/album.rb
CHANGED
data/lib/muzak/cmd/player.rb
CHANGED
data/lib/muzak/config.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "yaml"
|
2
|
+
require "fileutils"
|
2
3
|
|
3
4
|
module Muzak
|
4
5
|
# Muzak's static configuration dumping ground.
|
@@ -13,7 +14,7 @@ module Muzak
|
|
13
14
|
else
|
14
15
|
@config = {
|
15
16
|
"debug" => false,
|
16
|
-
"verbose" =>
|
17
|
+
"verbose" => true,
|
17
18
|
"music" => File.expand_path("~/music"),
|
18
19
|
"player" => "mpv",
|
19
20
|
"index-autobuild" => 86400,
|
@@ -21,12 +22,21 @@ module Muzak
|
|
21
22
|
"jukebox-size" => 100
|
22
23
|
}
|
23
24
|
|
24
|
-
|
25
|
+
[CONFIG_DIR, PLAYLIST_DIR, USER_PLUGIN_DIR, USER_COMMAND_DIR].each do |d|
|
26
|
+
FileUtils.mkdir_p d
|
27
|
+
end
|
28
|
+
|
29
|
+
sync!
|
25
30
|
end
|
26
31
|
|
27
|
-
@config.each do |key,
|
32
|
+
@config.each do |key, _|
|
28
33
|
define_singleton_method Utils.resolve_command(key) do
|
29
|
-
|
34
|
+
@config[key]
|
35
|
+
end
|
36
|
+
|
37
|
+
define_singleton_method "#{Utils.resolve_command(key)}=" do |value|
|
38
|
+
@config[key] = value
|
39
|
+
sync!
|
30
40
|
end
|
31
41
|
end
|
32
42
|
|
@@ -36,6 +46,10 @@ module Muzak
|
|
36
46
|
false
|
37
47
|
end
|
38
48
|
|
49
|
+
def self.sync!
|
50
|
+
File.open(CONFIG_FILE, "w") { |io| io.write @config.to_yaml }
|
51
|
+
end
|
52
|
+
|
39
53
|
# @return [Boolean] whether or not the given plugin is configured
|
40
54
|
# @note the truth-value of this method is used to determine which
|
41
55
|
# plugins should be loaded.
|
data/lib/muzak/const.rb
CHANGED
data/lib/muzak/index.rb
CHANGED
@@ -3,6 +3,10 @@ module Muzak
|
|
3
3
|
class Index
|
4
4
|
include Utils
|
5
5
|
|
6
|
+
def self.load_index!
|
7
|
+
Index.new(Config.music, deep: Config.deep_index)
|
8
|
+
end
|
9
|
+
|
6
10
|
# @return [String] the path of the root of the music tree
|
7
11
|
attr_accessor :tree
|
8
12
|
|
@@ -54,6 +58,7 @@ module Muzak
|
|
54
58
|
# @note The behavior of this method is affected by the value of
|
55
59
|
# {Muzak::Config.index_autobuild}.
|
56
60
|
def outdated?
|
61
|
+
return false unless Config.index_autobuild
|
57
62
|
Time.now.to_i - timestamp >= Config.index_autobuild
|
58
63
|
end
|
59
64
|
|
@@ -155,12 +160,22 @@ module Muzak
|
|
155
160
|
|
156
161
|
if music?(file)
|
157
162
|
index_hash["artists"][artist]["albums"][album]["songs"] << file
|
158
|
-
|
163
|
+
if deep?
|
164
|
+
index_hash["artists"][artist]["albums"][album]["deep-songs"] << Song.new(file)
|
165
|
+
end
|
159
166
|
end
|
160
167
|
end
|
161
168
|
|
162
169
|
index_hash["artists"][artist]["albums"][album]["songs"].sort!
|
163
|
-
|
170
|
+
|
171
|
+
# if any of the track numbers in the album are > 0 (the fallback),
|
172
|
+
# sort by ID3 track numbers. otherwise, hope that the song
|
173
|
+
# paths contain track numbers (e.g, "01 song.mp3").
|
174
|
+
if index_hash["artists"][artist]["albums"][album]["deep-songs"].any? { |s| s.track > 0 }
|
175
|
+
index_hash["artists"][artist]["albums"][album]["deep-songs"].sort_by!(&:track)
|
176
|
+
else
|
177
|
+
index_hash["artists"][artist]["albums"][album]["deep-songs"].sort_by!(&:path)
|
178
|
+
end
|
164
179
|
end
|
165
180
|
end
|
166
181
|
|
data/lib/muzak/instance.rb
CHANGED
@@ -34,7 +34,9 @@ module Muzak
|
|
34
34
|
def initialize(opts = {})
|
35
35
|
verbose "muzak is starting..."
|
36
36
|
|
37
|
-
|
37
|
+
error! "#{Config.music} doesn't exist" unless File.exist?(Config.music)
|
38
|
+
|
39
|
+
@index = Index.load_index!
|
38
40
|
|
39
41
|
@player = Player.load_player!(self)
|
40
42
|
|
data/lib/muzak/utils.rb
CHANGED
@@ -89,6 +89,14 @@ module Muzak
|
|
89
89
|
output pretty(:red, "error"), "[#{self.class.name}]", args
|
90
90
|
end
|
91
91
|
|
92
|
+
# Outputs a boxed error message and then exits.
|
93
|
+
# @param args [Array<String>] the message(s)
|
94
|
+
# @return [void]
|
95
|
+
def error!(*args)
|
96
|
+
error *args
|
97
|
+
exit 1
|
98
|
+
end
|
99
|
+
|
92
100
|
# Outputs a boxed debugging message.
|
93
101
|
# @param args [Array<String>] the message(s)
|
94
102
|
# @return [void]
|
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.0.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Woodruff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: taglib-ruby
|