-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Description
Code
require "pp"
require "ruby-mpd"
mpd = MPD.new
mpd.connect
begin
playlist = MPD::Playlist.new(mpd, "Example")
playlist.add("http://uk1.internet-radio.com:8106/listen.pls")
pp playlist.songs
ensure
mpd.disconnect
endOutput
Files inside Playlist 'Example' do not exist!
[]
I've checked the code and found this implementation of MPD::Playlist#songs:
# Lists the songs in the playlist. Playlist plugins are supported.
# @return [Array<MPD::Song>] songs in the playlist.
def songs
result = @mpd.send_command(:listplaylistinfo, @name)
result.map do |hash|
if hash[:file] && !hash[:file].match(/^(https?:\/\/)?/)[0].empty?
Song.new(@mpd, {:file => hash[:file], :time => [0]})
else
Song.new(@mpd, hash)
end
end
rescue TypeError
puts "Files inside Playlist '#{@name}' do not exist!"
return []
rescue NotFound
return [] # we rescue in the case the playlist doesn't exist.
endThe problem is, that result looks like this:
[ "http://uk1.internet-radio.com:8106/listen.pls" ]But the code requires result to look like this:
[ { :file => "http://uk1.internet-radio.com:8106/listen.pls" } ]Edit: I am using MPD 0.18.0
Metadata
Metadata
Assignees
Labels
No labels