muzak 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/muzak +3 -1
- data/bin/muzakd +5 -6
- data/lib/muzak/cmd/config.rb +2 -1
- data/lib/muzak/cmd/meta.rb +0 -1
- data/lib/muzak/cmd/playlist.rb +18 -41
- data/lib/muzak/const.rb +1 -1
- data/lib/muzak/player/mpv.rb +5 -1
- data/lib/muzak/playlist.rb +40 -17
- data/lib/muzak/song.rb +1 -1
- 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: 9a2a198cce10bc3f66a9c3c532433f30c4264b30
|
4
|
+
data.tar.gz: 2e021ffbcbc1d2b16696f010690389c1854b5890
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fe05e1fb8c85576a9b270144447f45e6c03d7b499f6569290f42c047a878d58c637ae36b8adcad3c8176c048136670ecf1079c6ccc4fa0dd2b09e67c77f17e2
|
7
|
+
data.tar.gz: cb384c8a927cd5ef336f6eb113c115d7a1d5a7f6e1adf66c16de2fe1559b056192b51d7f63f23478a01ffcf55b9cc67a57cb05981b272b2564906a71cabaadff
|
data/bin/muzak
CHANGED
@@ -45,5 +45,7 @@ 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
|
-
|
48
|
+
cmd = cmd_argv.shift
|
49
|
+
muzak.command cmd, *cmd_argv
|
50
|
+
break if cmd == "quit"
|
49
51
|
end
|
data/bin/muzakd
CHANGED
@@ -17,15 +17,14 @@ fifo_path = File.join(Muzak::CONFIG_DIR, "muzak.fifo")
|
|
17
17
|
File.delete(fifo_path) if File.exist?(fifo_path) # just in case a previous session died
|
18
18
|
File.mkfifo(fifo_path)
|
19
19
|
|
20
|
-
File.open(fifo_path, "r") do |fifo|
|
20
|
+
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
|
-
|
24
|
+
cmd = cmd_argv.shift
|
25
|
+
muzak.command cmd, *cmd_argv
|
26
|
+
break if cmd == "quit"
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
28
|
-
|
29
|
-
at_exit do
|
30
|
-
File.delete(fifo_path) if File.exist?(fifo_path)
|
31
|
-
end
|
30
|
+
File.delete(fifo_path) if File.exist?(fifo_path)
|
data/lib/muzak/cmd/config.rb
CHANGED
data/lib/muzak/cmd/meta.rb
CHANGED
data/lib/muzak/cmd/playlist.rb
CHANGED
@@ -1,18 +1,10 @@
|
|
1
1
|
module Muzak
|
2
2
|
module Cmd
|
3
|
-
def _playlist_file(pname)
|
4
|
-
File.join(PLAYLIST_DIR, pname) + ".yml"
|
5
|
-
end
|
6
|
-
|
7
|
-
def _playlist_available?(pname)
|
8
|
-
File.exist?(_playlist_file(pname))
|
9
|
-
end
|
10
|
-
|
11
3
|
def _playlist_loaded?
|
12
4
|
!!@playlist
|
13
5
|
end
|
14
6
|
|
15
|
-
def list_playlists
|
7
|
+
def list_playlists(*args)
|
16
8
|
Playlist.playlist_names.each do |playlist|
|
17
9
|
info playlist
|
18
10
|
end
|
@@ -22,14 +14,8 @@ module Muzak
|
|
22
14
|
fail_arity(args, 1)
|
23
15
|
pname = args.shift
|
24
16
|
|
25
|
-
|
26
|
-
|
27
|
-
@playlist = Playlist.load_playlist(_playlist_file(pname))
|
28
|
-
else
|
29
|
-
info "creating playlist '#{pname}'"
|
30
|
-
@playlist = Playlist.new(pname, [])
|
31
|
-
playlist_sync
|
32
|
-
end
|
17
|
+
info "loading playlist '#{pname}'"
|
18
|
+
@playlist = Playlist.new(pname)
|
33
19
|
|
34
20
|
event :playlist_loaded, @playlist
|
35
21
|
end
|
@@ -40,21 +26,11 @@ module Muzak
|
|
40
26
|
|
41
27
|
debug "deleting playist '#{pname}'"
|
42
28
|
|
43
|
-
|
29
|
+
Playlist.delete!(pname)
|
44
30
|
@playlist = nil
|
45
31
|
end
|
46
32
|
|
47
|
-
def
|
48
|
-
return unless _playlist_loaded?
|
49
|
-
fail_arity(args, 0)
|
50
|
-
|
51
|
-
debug "syncing playlist '#{@playlist.name}'"
|
52
|
-
|
53
|
-
Dir.mkdir(PLAYLIST_DIR) unless Dir.exist?(PLAYLIST_DIR)
|
54
|
-
File.open(_playlist_file(@playlist.name), "w") { |io| io.write @playlist.to_hash.to_yaml }
|
55
|
-
end
|
56
|
-
|
57
|
-
def enqueue_playlist
|
33
|
+
def enqueue_playlist(*args)
|
58
34
|
return unless _playlist_loaded?
|
59
35
|
|
60
36
|
@player.enqueue_playlist(@playlist)
|
@@ -70,33 +46,34 @@ module Muzak
|
|
70
46
|
album = @index.albums[album_name]
|
71
47
|
return if album.nil?
|
72
48
|
|
73
|
-
|
49
|
+
@playlist.add(album.songs)
|
50
|
+
end
|
51
|
+
|
52
|
+
def playlist_add_artist(*args)
|
53
|
+
return unless _playlist_loaded?
|
54
|
+
|
55
|
+
artist = args.join(" ")
|
56
|
+
return if artist.nil?
|
74
57
|
|
75
|
-
|
58
|
+
@playlist.add(@index.songs_by(artist))
|
76
59
|
end
|
77
60
|
|
78
|
-
def playlist_add_current
|
61
|
+
def playlist_add_current(*args)
|
79
62
|
return unless @player.running? && _playlist_loaded?
|
80
63
|
|
81
64
|
@playlist.add @player.now_playing
|
82
|
-
|
83
|
-
playlist_sync
|
84
65
|
end
|
85
66
|
|
86
|
-
def playlist_del_current
|
67
|
+
def playlist_del_current(*args)
|
87
68
|
return unless @player.running? && _playlist_loaded?
|
88
69
|
|
89
|
-
@playlist.delete
|
90
|
-
|
91
|
-
playlist_sync
|
70
|
+
@playlist.delete @player.now_playing
|
92
71
|
end
|
93
72
|
|
94
|
-
def playlist_shuffle
|
73
|
+
def playlist_shuffle(*args)
|
95
74
|
return unless _playlist_loaded?
|
96
75
|
|
97
76
|
@playlist.shuffle!
|
98
|
-
|
99
|
-
playlist_sync
|
100
77
|
end
|
101
78
|
end
|
102
79
|
end
|
data/lib/muzak/const.rb
CHANGED
data/lib/muzak/player/mpv.rb
CHANGED
@@ -22,6 +22,10 @@ module Muzak
|
|
22
22
|
@sock_path = Dir::Tmpname.make_tmpname("/tmp/mpv", ".sock")
|
23
23
|
mpv_args = [
|
24
24
|
"--idle",
|
25
|
+
# if i get around to separating album art from playback,
|
26
|
+
# these two flags disable mpv's video output entirely
|
27
|
+
# "--no-force-window",
|
28
|
+
# "--no-video",
|
25
29
|
"--no-osc",
|
26
30
|
"--no-osd-bar",
|
27
31
|
"--no-input-default-bindings",
|
@@ -151,7 +155,7 @@ module Muzak
|
|
151
155
|
|
152
156
|
def load_song(song, art)
|
153
157
|
cmds = ["loadfile", song.path, "append-play"]
|
154
|
-
cmds << "external-file
|
158
|
+
cmds << "external-file=\"#{art}\"" if art
|
155
159
|
command *cmds
|
156
160
|
end
|
157
161
|
|
data/lib/muzak/playlist.rb
CHANGED
@@ -1,6 +1,18 @@
|
|
1
1
|
module Muzak
|
2
2
|
class Playlist
|
3
|
-
attr_accessor :
|
3
|
+
attr_accessor :filename, :songs
|
4
|
+
|
5
|
+
def self.path_for(pname)
|
6
|
+
File.join(PLAYLIST_DIR, pname) + ".yml"
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.exist?(pname)
|
10
|
+
File.exist?(path_for(pname))
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.delete!(pname)
|
14
|
+
File.delete(path_for(pname)) if exist? pname
|
15
|
+
end
|
4
16
|
|
5
17
|
def self.playlist_names
|
6
18
|
Dir.entries(PLAYLIST_DIR).reject do |ent|
|
@@ -10,36 +22,47 @@ module Muzak
|
|
10
22
|
end
|
11
23
|
end
|
12
24
|
|
13
|
-
def
|
14
|
-
|
15
|
-
playlist_hash = YAML.load_file(path)
|
16
|
-
|
17
|
-
instance.name = File.basename(path, File.extname(path))
|
18
|
-
instance.songs = playlist_hash["songs"]
|
25
|
+
def initialize(pname)
|
26
|
+
@filename = self.class.path_for pname
|
19
27
|
|
20
|
-
|
28
|
+
if File.exist?(@filename)
|
29
|
+
phash = YAML.load_file(@filename)
|
30
|
+
@songs = phash["songs"]
|
31
|
+
else
|
32
|
+
@songs = []
|
33
|
+
end
|
21
34
|
end
|
22
35
|
|
23
|
-
def
|
24
|
-
@
|
25
|
-
@songs = songs
|
36
|
+
def name
|
37
|
+
File.basename(@filename, File.extname(@filename))
|
26
38
|
end
|
27
39
|
|
28
|
-
def add(
|
29
|
-
|
30
|
-
|
40
|
+
def add(songs)
|
41
|
+
# coerce a single song into an array
|
42
|
+
[*songs].each do |song|
|
43
|
+
next if @songs.include?(song)
|
44
|
+
@songs << song
|
45
|
+
end
|
46
|
+
|
47
|
+
sync!
|
31
48
|
end
|
32
49
|
|
33
|
-
def delete(
|
34
|
-
@songs.delete(song)
|
50
|
+
def delete(songs)
|
51
|
+
[*songs].each { |song| @songs.delete(song) }
|
52
|
+
|
53
|
+
sync!
|
35
54
|
end
|
36
55
|
|
37
56
|
def shuffle!
|
38
57
|
@songs.shuffle!
|
39
58
|
end
|
40
59
|
|
60
|
+
def sync!
|
61
|
+
File.open(@filename, "w") { |io| io.write to_hash.to_yaml }
|
62
|
+
end
|
63
|
+
|
41
64
|
def to_hash
|
42
|
-
{ "songs" => songs }
|
65
|
+
{ "songs" => @songs }
|
43
66
|
end
|
44
67
|
end
|
45
68
|
end
|
data/lib/muzak/song.rb
CHANGED
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.7
|
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-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: taglib-ruby
|