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
< $Id$
<
< 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
< it under the terms of the GNU General Public License as published by
......@@ -26,53 +27,66 @@ vim:syntax=lua
]] ?>
<?vlc
--[[
function a(t,pre)
local pre = pre or ""
for k,v in pairs(t) do
vlc.msg.err(pre..tostring(k).." : "..tostring(v))
if type(v) == "table" then
a(v,pre.." ")
--package.loaded.httprequests = nil --uncomment to debug changes
require "httprequests"
local printleaf = function(item)
print ("\n<leaf")
for k,v in pairs(item) do
if (k~="type") then
print(" "..k.."=\""..v.."\"")
end
end
print ("/>")
end
--]]
function print_playlist(item)
if item.flags.disabled then return end
if(item.children) then
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 _, child in ipairs(item.children) do
print_playlist(child)
end
print('</node>')
local printnode = function(item)
local children=NULL
print ("\n<node")
for k,v in pairs(item) do
if (k=="type") then
elseif (k=="children") then
children=v._array
else
local name, path = vlc.strings.convert_xml_special_chars(item.name or "", item.path or "")
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
print(" "..k.."=\""..v.."\"")
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
print (">")
return children
end
local p
if _GET["search"] then
if _GET["search"] ~= "" then
_G.search_key = _GET["search"]
printitem = function(item)
local children=NULL
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
_G.search_key = nil
printleaf(item)
end
local key = vlc.strings.decode_uri(_GET["search"])
p = vlc.playlist.search(key)
else
p = vlc.playlist.get()
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