muzak 0.0.4 → 0.0.5

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: 3f7427db5881fd8253e6159081edcb049c221d83
4
- data.tar.gz: 6e19639939bddfad3fdd995b741bacc7113c5531
3
+ metadata.gz: 2083f3ba445039c9dea5b52f8bd2383238eb4ea7
4
+ data.tar.gz: c3b1aaca1e968d7da6c104549c63cd8adfb23a3c
5
5
  SHA512:
6
- metadata.gz: 5677c46efa1bfb8176e94d06d0c2793856e08978f46421cd6ba5b42c9b50370b42a57c5f833757b15c8f267682cdcceffeb7df82c653ebb1b5b0967b61cbacc5
7
- data.tar.gz: 5d60702cd8a71f06ea06e2dc728187327f8913d67bc8a630a61cc659d729cb4a905264c558b8ed11c70e6c5575d4d68c7215e01743cd1e8a2fdbd87dee840244
6
+ metadata.gz: 62a18069ad690e2c07fe3a87840a32b3d02c0f82f041c05dca890db1a0637c0d5c935d06665c03276f2878f2eadbda1fec7bd0a2db0173cfa1fc94cde522fda6
7
+ data.tar.gz: 7f147ea2f6002c33e3e8fd6a996b0d4a136408e7dc556ca8d44510befd67514cbdae541bd98f5c64142d3ede5370d0fe5e38a72e74d4f0b7d1fa238c9a8c125e
data/bin/muzak CHANGED
@@ -45,5 +45,5 @@ trap("INT", "SIG_IGN")
45
45
  while line = Readline.readline("muzak> ", true)
46
46
  cmd_argv = Shellwords.split(line) rescue next
47
47
  next if cmd_argv.empty? || cmd_argv.any?(&:empty?)
48
- muzak.send Muzak::Cmd.resolve_command(cmd_argv.shift), *cmd_argv
48
+ muzak.command cmd_argv.shift, *cmd_argv
49
49
  end
data/bin/muzakd CHANGED
@@ -21,7 +21,7 @@ File.open(fifo_path, "r") do |fifo|
21
21
  loop do
22
22
  cmd_argv = Shellwords.split(fifo.readline) rescue next
23
23
  next if cmd_argv.empty? || cmd_argv.any?(&:empty?)
24
- muzak.send Muzak::Cmd.resolve_command(cmd_argv.shift), *cmd_argv
24
+ muzak.command cmd_argv.shift, *cmd_argv
25
25
  end
26
26
  end
27
27
 
@@ -68,6 +68,14 @@ module Muzak
68
68
  @player.enqueue_album album
69
69
  end
70
70
 
71
+ def jukebox(*args)
72
+ count = args.shift || @config["jukebox-size"]
73
+
74
+ songs = @index.jukebox(count.to_i).map { |s| Song.new(s) }
75
+
76
+ songs.each { |s| @player.enqueue_song s }
77
+ end
78
+
71
79
  def list_queue
72
80
  puts @player.list_queue.map(&:title)
73
81
  end
@@ -81,6 +89,8 @@ module Muzak
81
89
  end
82
90
 
83
91
  def now_playing
92
+ return unless @player.playing?
93
+
84
94
  info @player.now_playing.full_title
85
95
  end
86
96
  end
@@ -1,5 +1,5 @@
1
1
  module Muzak
2
- VERSION = "0.0.4".freeze
2
+ VERSION = "0.0.5".freeze
3
3
 
4
4
  CONFIG_DIR = File.expand_path("~/.config/muzak").freeze
5
5
  CONFIG_FILE = File.join(CONFIG_DIR, "muzak.yml").freeze
@@ -69,6 +69,12 @@ module Muzak
69
69
  end
70
70
  end
71
71
 
72
+ def jukebox(count = 50)
73
+ @all_albums ||= @hash["artists"].map { |_, a| a["albums"] }.flatten
74
+ @all_songs ||= @all_albums.map { |aa| aa.map { |_, a| a["songs"] } }.flatten
75
+ @all_songs.sample(count)
76
+ end
77
+
72
78
  def songs_by(artist)
73
79
  error "no such artist: '#{artist}'" unless @hash["artists"].key?(artist)
74
80
 
@@ -3,6 +3,10 @@ module Muzak
3
3
  include Cmd
4
4
  include Utils
5
5
 
6
+ def command(cmd, *args)
7
+ send Cmd.resolve_command(cmd), *args
8
+ end
9
+
6
10
  def method_missing(meth, *args)
7
11
  warn "unknown command: #{Cmd.resolve_method(meth)}"
8
12
  help
@@ -27,6 +31,7 @@ module Muzak
27
31
  @plugins = initialize_plugins!
28
32
 
29
33
  playlist_load @config["default-playlist"] if @config["default-playlist"]
34
+ enqueue_playlist if _playlist_loaded? && @config["autoplay"]
30
35
  end
31
36
 
32
37
  def initialize_plugins!
@@ -130,14 +130,20 @@ module Muzak
130
130
  end
131
131
 
132
132
  def shuffle_queue
133
+ return unless running?
134
+
133
135
  command "playlist-shuffle"
134
136
  end
135
137
 
136
138
  def clear_queue
139
+ return unless running?
140
+
137
141
  command "playlist-clear"
138
142
  end
139
143
 
140
144
  def now_playing
145
+ return unless running? && playing?
146
+
141
147
  Song.new(get_property "path")
142
148
  end
143
149
 
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
4
+ version: 0.0.5
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-08 00:00:00.000000000 Z
11
+ date: 2016-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: taglib-ruby