Commit 7ff6d243 authored by Rob Jonson's avatar Rob Jonson Committed by Rémi Denis-Courmont

playlist.xml now draws it's data from the common model in httprequests.lua...

playlist.xml now draws it's data from the common model in httprequests.lua output data is the same for backwards compatibility
Signed-off-by: default avatarRémi Denis-Courmont <remi@remlab.net>
parent 5db979bb
...@@ -8,6 +8,7 @@ vim:syntax=lua ...@@ -8,6 +8,7 @@ vim:syntax=lua
< $Id$ < $Id$
< <
< Authors: Antoine Cellerier <dionoea -at- videolan -dot- org> < Authors: Antoine Cellerier <dionoea -at- videolan -dot- org>
< Authors: Rob Jonson <rob -at- hobbyistsoftware -dot- com>
< <
< This program is free software; you can redistribute it and/or modify < This program is free software; you can redistribute it and/or modify
< it under the terms of the GNU General Public License as published by < it under the terms of the GNU General Public License as published by
...@@ -26,53 +27,66 @@ vim:syntax=lua ...@@ -26,53 +27,66 @@ vim:syntax=lua
]] ?> ]] ?>
<?vlc <?vlc
--[[
function a(t,pre) --package.loaded.httprequests = nil --uncomment to debug changes
local pre = pre or "" require "httprequests"
for k,v in pairs(t) do
vlc.msg.err(pre..tostring(k).." : "..tostring(v)) local printleaf = function(item)
if type(v) == "table" then print ("\n<leaf")
a(v,pre.." ")
for k,v in pairs(item) do
if (k~="type") then
print(" "..k.."=\""..v.."\"")
end end
end end
print ("/>")
end end
--]]
local printnode = function(item)
function print_playlist(item) local children=NULL
if item.flags.disabled then return end
if(item.children) then print ("\n<node")
local name = vlc.strings.convert_xml_special_chars(item.name or "")
print('<node id="' ..tostring(item.id).. '" name="' ..tostring(name).. '" ro="' ..(item.flags.ro and "ro" or "rw").. '">') for k,v in pairs(item) do
for _, child in ipairs(item.children) do
print_playlist(child) if (k=="type") then
end
print('</node>') elseif (k=="children") then
children=v._array
else else
local name, path = vlc.strings.convert_xml_special_chars(item.name or "", item.path or "") print(" "..k.."=\""..v.."\"")
local current_item = vlc.input.item()
local current = ""
-- Is the item the one currently played
if(current_item ~= nil) then
if(vlc.input.item().uri(current_item) == path) then
current = 'current="current"'
end
end end
print('<leaf id="' ..tostring(item.id).. '" uri="' ..tostring(path).. '" name="' ..name.. '" ro="' ..(item.flags.ro and "ro" or "rw").. '" duration ="' ..math.floor(item.duration).. '" ' ..current.. ' />')
end end
print (">")
return children
end end
local p printitem = function(item)
if _GET["search"] then local children=NULL
if _GET["search"] ~= "" then
_G.search_key = _GET["search"] if item.type=="node" then
children=printnode(item)
if (children) then
for i,v in ipairs(children) do
printitem(v)
end
end
print ("</node>")
else else
_G.search_key = nil printleaf(item)
end end
local key = vlc.strings.decode_uri(_GET["search"])
p = vlc.playlist.search(key)
else
p = vlc.playlist.get()
end end
--a(p) --Uncomment to debug
print_playlist(p) httprequests.processcommands()
local pt=httprequests.playlisttable()
printitem(pt)
?> ?>
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment