home *** CD-ROM | disk | FTP | other *** search
/ mail.altrad.com / 2015.02.mail.altrad.com.tar / mail.altrad.com / TEST / vlc-2-0-5-win32.exe / lua / http / requests / vlm.xml < prev   
Extensible Markup Language  |  2012-12-12  |  4KB  |  158 lines

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