]> git.sesse.net Git - vlc/commitdiff
playlist.xml now draws it's data from the common model in httprequests.lua output...
authorRob Jonson <rob@hobbyistsoftware.com>
Sun, 25 Sep 2011 21:59:56 +0000 (22:59 +0100)
committerRémi Denis-Courmont <remi@remlab.net>
Mon, 26 Sep 2011 14:54:52 +0000 (17:54 +0300)
Signed-off-by: Rémi Denis-Courmont <remi@remlab.net>
share/lua/http/requests/playlist.xml

index 23fdb64b952c9bca0af549f4580f8ea1ea55dd54..745237f2c292d3a72148fde1d3c9f09fa220735a 100644 (file)
@@ -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
-  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>')
-    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
-        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.. ' />')
+
+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
+                       print(" "..k.."=\""..v.."\"")
+               end
     end
+
+       print (">")
+
+       return children
 end
 
-local p
-if _GET["search"] then
-  if _GET["search"] ~= "" then
-    _G.search_key = _GET["search"]
-  else
-    _G.search_key = nil
-  end
-  local key = vlc.strings.decode_uri(_GET["search"])
-  p = vlc.playlist.search(key)
-else
-  p = vlc.playlist.get()
+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
+               printleaf(item)
+       end
+
 end
---a(p) --Uncomment to debug
-print_playlist(p)
-?>
+
+httprequests.processcommands()
+
+local pt=httprequests.playlisttable()
+
+printitem(pt)
+
+
+?>
\ No newline at end of file