1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
|
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<?vlc --[[
vim:syntax=lua
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >
< vlm.xml: VLC media player web interface
< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >
< Copyright (C) 2005-2006 the VideoLAN team
<
< Authors: Antoine Cellerier <dionoea -at- videolan -dot- org>
<
< 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
< the Free Software Foundation; either version 2 of the License, or
< (at your option) any later version.
<
< This program is distributed in the hope that it will be useful,
< but WITHOUT ANY WARRANTY; without even the implied warranty of
< MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
< GNU General Public License for more details.
<
< You should have received a copy of the GNU General Public License
< along with this program; if not, write to the Free Software
< Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
]]
local function insert_children(c,t)
if c.children then
for _, d in ipairs(c.children) do
table.insert(t,d.value or d.name)
end
end
end
local function print_table(name,t)
print("<"..name.."s>")
if #t ~= 0 then
for _,v in ipairs(t) do
print("<"..name..">")
print(vlc.strings.convert_xml_special_chars(v))
print("</"..name..">")
end
end
print("</"..name.."s>")
end
local function print_media(m)
local name = m.name
local type_, enabled, output
local loop = ""
local inputs = {}
local options = {}
local instances = {}
for _,c in ipairs(m.children) do
if c.name=="type" then
type_ = c.value
elseif c.name=="enabled" then
enabled = c.value
elseif c.name=="loop" then
loop = c.value
elseif c.name=="output" then
output = c.value
elseif c.name=="inputs" then
insert_children(c,inputs)
elseif c.name=="options" then
insert_children(c,options)
elseif c.name=="instances" then
if c.children then
for _, d in ipairs(c.children) do
local instance = "<instance "
for _,e in ipairs(d.children) do
instance = instance .. vlc.strings.convert_xml_special_chars(e.name) .. "=\"" .. vlc.strings.convert_xml_special_chars(e.value) .. "\" "
end
instance = instance .. "/>"
table.insert(instances,instance)
end
end
end
end
print("<"..type_.." name=\""..vlc.strings.convert_xml_special_chars(name).."\" enabled=\""..vlc.strings.convert_xml_special_chars(enabled).."\" loop=\""..vlc.strings.convert_xml_special_chars(loop).."\">\n")
print("<output>"..vlc.strings.convert_xml_special_chars(output).."</output>\n")
print_table("input",inputs)
print_table("option",options)
print "<instances>\n"
if #instances ~= 0 then
print(table.concat(instances))
end
print "</instances>\n"
print("</"..type_..">\n")
end
local function print_schedule(m)
local name = m.name
local enabled, date, period, repeat_ = "", "", "", ""
local commands = {}
for _,c in ipairs(m.children) do
if c.name=="enabled" then
enabled = c.value
elseif c.name=="date" then
date = c.value
elseif c.name=="period" then
period = c.value
elseif c.name=="repeat" then
repeat_ = c.value
elseif c.name=="commands" then
insert_children(c,commands)
end
end
print("<schedule name=\""..vlc.strings.convert_xml_special_chars(name).."\" enabled=\""..vlc.strings.convert_xml_special_chars(enabled).."\" period=\""..vlc.strings.convert_xml_special_chars(period).."\" repeat=\""..vlc.strings.convert_xml_special_chars(repeat_).."\">\n")
print_table("command",commands)
print("</schedule>\n")
end
local function print_xml(m)
print "<vlm>"
if m then
for _, c in ipairs(m.children) do
if c.name=="media" and c.children then
for _, d in ipairs(c.children) do
print_media(d)
end
elseif c.name=="schedule" and c.children then
for _, d in ipairs(c.children) do
print_schedule(d)
end
end
end
else
print "oops"
end
print "</vlm>"
end
local function print_msg(m)
if not m then return end
print("<"..m.name..">\n")
if m.children then
for _, child in ipairs(m.children) do
print_msg(child)
end
elseif m.value then
print(m.value)
end
print("</"..m.name..">\n")
end
local msg = vlm:execute_command("show")
print_xml(msg)
--print_msg(msg)
?>
|