Commit 2ff13467 authored by Julien 'Lta' BALLET's avatar Julien 'Lta' BALLET Committed by Jean-Baptiste Kempf

Implement lazy loading in icelast.lua, fix doc

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 648b2bc7
......@@ -27,12 +27,12 @@ VLC Lua SD modules should define two functions:
User defined modules stored in the share/lua/modules/ directory are
available. Read the 'Two pass Initialization section'
available. Read the 'Lazy initialization' section
Available VLC specific Lua modules: input, msg, net, object, sd,
strings, variables, stream, gettext, xml. See lua/README.txt.
## Two pass Initialization
## Lazy Initialization
SD Lua scripts are actually ran in two different contexts/interpreters. One of
them is the one that will call your main() and search() functions. The other one
......@@ -51,8 +51,9 @@ lazily_loaded = false
dkjson = nil
function lazy_load()
if lazily_loaded ~= false then return nil end
if lazily_loaded then return nil end
dkjson = require("dkjson")
lazily_loaded = true
end
function descriptor()
......
......@@ -19,7 +19,14 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
--]]
require "simplexml"
lazily_loaded = false
function lazy_load()
if lazily_loaded then return nil end
require "simplexml"
lazily_loaded = true
end
function descriptor()
return { title="Icecast Radio Directory" }
......@@ -30,6 +37,7 @@ function dropnil(s)
end
function main()
lazy_load()
local tree = simplexml.parse_url("http://dir.xiph.org/yp.xml")
for _, station in ipairs( tree.children ) do
simplexml.add_name_maps( station )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment