[vlc-commits] playlist.xml now draws it's data from the common model in httprequests. lua output data is the same for backwards compatibility

Rob Jonson git at videolan.org
Mon Sep 26 16:58:34 CEST 2011


vlc | branch: master | Rob Jonson <rob at hobbyistsoftware.com> | Sun Sep 25 22:59:56 2011 +0100| [7ff6d243f17340f7f080b0c007adbd3a86379b4a] | committer: Rémi Denis-Courmont

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: Rémi Denis-Courmont <remi at remlab.net>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7ff6d243f17340f7f080b0c007adbd3a86379b4a
---

 share/lua/http/requests/playlist.xml |  102 +++++++++++++++++++---------------
 1 files changed, 58 insertions(+), 44 deletions(-)

diff --git a/share/lua/http/requests/playlist.xml b/share/lua/http/requests/playlist.xml
index 23fdb64..745237f 100644
--- a/share/lua/http/requests/playlist.xml
+++ b/share/lua/http/requests/playlist.xml
@@ -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



More information about the vlc-commits mailing list