]> git.sesse.net Git - vlc/blob - share/lua/http/requests/playlist_jstree.xml
Correct spelling: s/[sS]yncro/[sS]ynchro/
[vlc] / share / lua / http / requests / playlist_jstree.xml
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$
9
10 <  Authors: Antoine Cellerier <dionoea -at- videolan -dot- org>
11
12 <  This program is free software; you can redistribute it and/or modify
13 <  it under the terms of the GNU General Public License as published by
14 <  the Free Software Foundation; either version 2 of the License, or
15 <  (at your option) any later version.
16
17 <  This program is distributed in the hope that it will be useful,
18 <  but WITHOUT ANY WARRANTY; without even the implied warranty of
19 <  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 <  GNU General Public License for more details.
21
22 <  You should have received a copy of the GNU General Public License
23 <  along with this program; if not, write to the Free Software
24 <  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25 < - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
26 ]] ?>
27 <root>
28 <?vlc
29 --[[
30 function a(t,pre)
31   local pre = pre or ""
32   for k,v in pairs(t) do
33     vlc.msg.err(pre..tostring(k).." : "..tostring(v))
34     if type(v) == "table" then
35       a(v,pre.."  ")
36     end
37   end
38 end
39 --]]
40
41 function print_playlist(item)
42     if item.flags.disabled then return end
43     if(item.children) then
44         local name = vlc.strings.convert_xml_special_chars(item.name or "")
45         if(name ~= "Undefined") then
46                         print('<item id="plid_' ..tostring(item.id).. '" name="' ..tostring(name).. '" ro="' ..(item.flags.ro and "ro" or "rw").. '"><content><name>' ..name.. '</name></content>')
47                         for _, child in ipairs(item.children) do
48                                 print_playlist(child)
49                         end
50                         print('</item>')
51                 else
52                         for _, child in ipairs(item.children) do
53                                 print_playlist(child)
54                         end
55                 end
56     else
57         local name, path = vlc.strings.convert_xml_special_chars(item.name or "", item.path or "")
58         local current_item = vlc.input.item()
59         local current = ""
60         -- Is the item the one currently played
61         if(current_item ~= nil) then
62             if(vlc.input.item().uri(current_item) == path) then
63                 current = 'current="current"'
64             end
65         end
66         print('<item id="plid_' ..tostring(item.id).. '" uri="' ..tostring(path).. '" name="' ..name.. '" ro="' ..(item.flags.ro and "ro" or "rw").. '" duration ="' ..math.floor(item.duration).. '" ' ..current.. ' ><content><name>' ..name.. '</name></content></item>')
67     end
68 end
69
70 local p
71 if _GET["search"] then
72   if _GET["search"] ~= "" then
73     _G.search_key = _GET["search"]
74   else
75     _G.search_key = nil
76   end
77   local key = vlc.strings.decode_uri(_GET["search"])
78   p = vlc.playlist.search(key)
79 else
80   p = vlc.playlist.get()
81 end
82 --a(p) --Uncomment to debug
83 print_playlist(p)
84 ?>
85 </root>