playlist.xml now draws it's data from the common model in httprequests.lua output...
[vlc.git] / share / lua / http / requests / playlist.xml
blob745237f2c292d3a72148fde1d3c9f09fa220735a
1 <?xml version="1.0" encoding="utf-8" standalone="yes" ?<?vlc print'>'?>
2 <?vlc --[[
3 vim:syntax=lua
4 <!--  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >
5 <  playlist.xml: VLC media player web interface
6 < - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >
7 <  Copyright (C) 2005-2006 the VideoLAN team
8 <  $Id$
10 <  Authors: Antoine Cellerier <dionoea -at- videolan -dot- org>
11 <  Authors: Rob Jonson <rob -at- hobbyistsoftware -dot- com>
13 <  This program is free software; you can redistribute it and/or modify
14 <  it under the terms of the GNU General Public License as published by
15 <  the Free Software Foundation; either version 2 of the License, or
16 <  (at your option) any later version.
18 <  This program is distributed in the hope that it will be useful,
19 <  but WITHOUT ANY WARRANTY; without even the implied warranty of
20 <  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 <  GNU General Public License for more details.
23 <  You should have received a copy of the GNU General Public License
24 <  along with this program; if not, write to the Free Software
25 <  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
26 < - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
27 ]] ?>
29 <?vlc
31 --package.loaded.httprequests = nil --uncomment to debug changes
32 require "httprequests"
34 local printleaf = function(item)
35         print ("\n<leaf")
37         for k,v in pairs(item) do
39                 if (k~="type") then
40                         print(" "..k.."=\""..v.."\"")
41                 end
42     end
44         print ("/>")
45 end
47 local printnode = function(item)
48         local children=NULL
50         print ("\n<node")
52         for k,v in pairs(item) do
54                 if (k=="type") then
56                 elseif (k=="children") then
57                         children=v._array
58                 else
59                         print(" "..k.."=\""..v.."\"")
60                 end
61     end
63         print (">")
65         return children
66 end
68 printitem = function(item)
69         local children=NULL
71         if item.type=="node" then
72                 children=printnode(item)
73                 if (children) then
74                         for i,v in ipairs(children) do
75                                 printitem(v)
76                         end
77                 end
78                 print ("</node>")
79         else
80                 printleaf(item)
81         end
83 end
85 httprequests.processcommands()
87 local pt=httprequests.playlisttable()
89 printitem(pt)