muzak 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fea7658ba10597fe2e70ededc6e8b33e179f200c
4
- data.tar.gz: b320dc1ef8a2b0aa715f336290d1e66fe0771a12
3
+ metadata.gz: bfec18a0835cc1c148e9bf4c1ee3c9770143ba46
4
+ data.tar.gz: 44f5b96244563e8161d6c9950079551b4554d80a
5
5
  SHA512:
6
- metadata.gz: 91fe7be79998568bb9b3727066561eb1fd9f82ce8d0a9be4829c45b13a13d59fb2ae2bce343fd9ab87202eb72862d192c402fe89438b84cf23efb9fd1f3df8e5
7
- data.tar.gz: 1352f596a7e5a7df41027c62600524faf2352baf7a39d48c9671647e1d01e9c80ca3cdcb6278f7e71b1fa22dd866fe10c933b6f4f394ac66eae789619a9e6e80
6
+ metadata.gz: 4c8c79d444285e835e753fe1582147a30de11bf96a9d3d18f2af54b116ff315937000a88ab1a2a8b1c89de767ac0692d95125bbbc01557cd42ed808c96173d68
7
+ data.tar.gz: bbe8db2c4bdbe6f0df3eea079de83795ef4638437268ef779d5231ea8c3afde337e437335ff30a6899ab92d1defb8760f384f02b72c59524b842beefcd67b151
data/README.md CHANGED
@@ -18,7 +18,7 @@ Muzak is still a work in process. Don't expect stability or pleasant output.
18
18
  On the command-line:
19
19
 
20
20
  ```shell
21
- $ ruby -Ilib bin/muzak.rb # flags: --verbose, --debug
21
+ $ ruby -Ilib bin/muzak.rb
22
22
  muzak> help
23
23
  ```
24
24
 
@@ -37,4 +37,3 @@ $ ruby -Ilib bin/muzak-cmd "command"
37
37
  * current indexing/sorting logic is terrible
38
38
  * all the documentation
39
39
  * readline's tab complete is terrible with spaces (maybe use `bond`?)
40
- * replace YAML index with a more space/time efficient format (JSON, msgpack, Marshal?)
data/bin/muzak CHANGED
@@ -4,14 +4,9 @@ require "muzak"
4
4
  require "readline"
5
5
  require "shellwords"
6
6
 
7
- opts = {
8
- debug: ARGV.include?("--debug") || ARGV.include?("-d"),
9
- verbose: ARGV.include?("--verbose") || ARGV.include?("-v"),
10
- }
7
+ Thread.abort_on_exception = Muzak::Config.debug
11
8
 
12
- Thread.abort_on_exception = opts[:debug]
13
-
14
- muzak = Muzak::Instance.new(opts)
9
+ muzak = Muzak::Instance.new
15
10
 
16
11
  COMMANDS = Muzak::Cmd.commands
17
12
 
data/bin/muzakd CHANGED
@@ -3,15 +3,10 @@
3
3
  require "muzak"
4
4
  require "shellwords"
5
5
 
6
- opts = {
7
- debug: ARGV.include?("--debug") || ARGV.include?("-d"),
8
- verbose: ARGV.include?("--verbose") || ARGV.include?("-v"),
9
- }
6
+ Process.daemon unless Muzak::Config.debug || Muzak::Config.verbose
7
+ Thread.abort_on_exception = Muzak::Config.debug
10
8
 
11
- Process.daemon unless opts[:debug] || opts[:verbose]
12
- Thread.abort_on_exception = opts[:debug]
13
-
14
- muzak = Muzak::Instance.new(opts)
9
+ muzak = Muzak::Instance.new
15
10
 
16
11
  fifo_path = File.join(Muzak::CONFIG_DIR, "muzak.fifo")
17
12
  File.delete(fifo_path) if File.exist?(fifo_path) # just in case a previous session died
@@ -6,6 +6,8 @@ module Muzak
6
6
  @config = YAML::load_file(CONFIG_FILE)
7
7
  else
8
8
  @config = {
9
+ "debug" => false,
10
+ "verbose" => false,
9
11
  "music" => File.expand_path("~/music"),
10
12
  "player" => "mpv",
11
13
  "index-autobuild" => 86400,
@@ -1,9 +1,9 @@
1
1
  module Muzak
2
- VERSION = "0.0.10".freeze
2
+ VERSION = "0.0.11".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
- INDEX_FILE = File.join(CONFIG_DIR, "index.yml").freeze
6
+ INDEX_FILE = File.join(CONFIG_DIR, "index.dat").freeze
7
7
  PLAYLIST_DIR = File.join(CONFIG_DIR, "playlists").freeze
8
8
  USER_PLUGIN_DIR = File.join(CONFIG_DIR, "plugins").freeze
9
9
  USER_COMMAND_DIR = File.join(CONFIG_DIR, "commands").freeze
@@ -9,7 +9,7 @@ module Muzak
9
9
 
10
10
  if File.exist?(INDEX_FILE)
11
11
  verbose "loading index from #{INDEX_FILE}"
12
- @hash = YAML::load_file(INDEX_FILE)
12
+ @hash = Marshal::load(File.read INDEX_FILE)
13
13
  return unless outdated?
14
14
  end
15
15
 
@@ -19,7 +19,9 @@ module Muzak
19
19
  def build!
20
20
  @hash = build_index_hash!
21
21
 
22
- File.open(INDEX_FILE, "w") { |io| io.write @hash.to_yaml }
22
+ debug "indexed #{albums.length} albums by #{artists.length} artists"
23
+
24
+ File.open(INDEX_FILE, "w") { |io| io.write Marshal::dump @hash }
23
25
  end
24
26
 
25
27
  def deep?
@@ -35,19 +37,21 @@ module Muzak
35
37
  end
36
38
 
37
39
  def artists
38
- @hash["artists"].keys
40
+ @artists ||= @hash["artists"].keys
39
41
  end
40
42
 
41
43
  def albums
42
- albums_hash = {}
44
+ @albums_hash ||= begin
45
+ albums_hash = {}
43
46
 
44
- artists.each do |a|
45
- @hash["artists"][a]["albums"].each do |title, album_hash|
46
- albums_hash[title] = Album.new(title, album_hash)
47
+ artists.each do |a|
48
+ @hash["artists"][a]["albums"].each do |title, album_hash|
49
+ albums_hash[title] = Album.new(title, album_hash)
50
+ end
47
51
  end
48
- end
49
52
 
50
- albums_hash
53
+ albums_hash
54
+ end
51
55
  end
52
56
 
53
57
  def album_names
@@ -55,9 +59,12 @@ module Muzak
55
59
  end
56
60
 
57
61
  def albums_by(artist)
58
- error "no such artist: '#{artist}'" unless @hash["artists"].key?(artist)
59
-
60
- @hash["artists"][artist]["albums"].map { |title, album| Album.new(title, album) }
62
+ if artists.include?(artist)
63
+ @hash["artists"][artist]["albums"].map { |title, album| Album.new(title, album) }
64
+ else
65
+ error "no such artist: '#{artist}'" unless @hash["artists"].key?(artist)
66
+ []
67
+ end
61
68
  end
62
69
 
63
70
  def jukebox(count = 50)
@@ -15,9 +15,6 @@ module Muzak
15
15
  attr_reader :index, :player, :plugins, :playlists
16
16
 
17
17
  def initialize(opts = {})
18
- $debug = opts[:debug]
19
- $verbose = opts[:verbose]
20
-
21
18
  verbose "muzak is starting..."
22
19
 
23
20
  @index = Index.new(Config.music, deep: Config.deep_index)
@@ -37,7 +34,7 @@ module Muzak
37
34
  plugins.each do |plugin|
38
35
  Thread.new do
39
36
  plugin.send(type, *args)
40
- end.join
37
+ end
41
38
  end
42
39
  end
43
40
  end
@@ -9,7 +9,7 @@ module Muzak
9
9
  end
10
10
 
11
11
  def music?(filename)
12
- [".mp3", ".flac", ".m4a", ".wav", ".ogg", ".oga", ".opus"].include?(File.extname(filename))
12
+ [".mp3", ".flac", ".m4a", ".wav", ".ogg", ".oga", ".opus"].include?(File.extname(filename.downcase))
13
13
  end
14
14
 
15
15
  def album_art?(filename)
@@ -17,11 +17,11 @@ module Muzak
17
17
  end
18
18
 
19
19
  def debug?
20
- !!$debug
20
+ Config.debug
21
21
  end
22
22
 
23
23
  def verbose?
24
- !!$verbose
24
+ Config.verbose
25
25
  end
26
26
 
27
27
  def pretty(color = :none, str)
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.10
4
+ version: 0.0.11
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-15 00:00:00.000000000 Z
11
+ date: 2016-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: taglib-ruby