summaryrefslogtreecommitdiff
path: root/main.lua
diff options
context:
space:
mode:
Diffstat (limited to 'main.lua')
-rw-r--r--main.lua66
1 files changed, 37 insertions, 29 deletions
diff --git a/main.lua b/main.lua
index 090395d..e9010c5 100644
--- a/main.lua
+++ b/main.lua
@@ -16,32 +16,7 @@ local _xc = require('xc')
local mp_utils = require('mp.utils')
local state = _state.new()
-
local downloader = _downloader.new({limit = 5})
-local xc = _xc.new({
- server = config.xc_server,
- user = config.xc_user,
- pass = config.xc_pass,
-})
-xc = cacher.wrap(xc, {
- directory = config.cache_dir,
- prefix = (xc.server:gsub('%W', '_')),
- time = 24*60*60,
- functions = {
- get_live_categories = true,
- get_live_streams = true,
- get_vod_categories = true,
- get_vod_streams = true,
- get_vod_info = true,
- get_series_categories = true,
- get_series = true,
- get_series_info = true,
- get_epg = true,
- },
-})
-
-local catalogue = _catalogue.new()
-local epg = _epg.new()
local osd
local function dl_img(url, path, cb)
@@ -71,10 +46,43 @@ osd = _osd.new({
})
local ctx = {
- catalogue = catalogue,
- epg = epg,
- xc = xc,
+ catalogue = _catalogue.new(),
+ src = {},
+ src_order = {},
}
+for _, v in ipairs(config.src_order) do
+ local src = config.src[v]
+ local xc = _xc.new({
+ url = src.url,
+ user = src.user,
+ pass = src.pass,
+ })
+ xc = cacher.wrap(xc, {
+ directory = config.cache_dir,
+ prefix = (xc.url:gsub('%W', '_')),
+ time = 24*60*60,
+ functions = {
+ get_live_categories = true,
+ get_live_streams = true,
+ get_vod_categories = true,
+ get_vod_streams = true,
+ get_vod_info = true,
+ get_series_categories = true,
+ get_series = true,
+ get_series_info = true,
+ get_epg = true,
+ },
+ })
+
+ ctx.src[v] = {
+ id = v,
+ name = src.name,
+ xc = xc,
+ epg = _epg.new(),
+ }
+ ctx.src_order[#ctx.src_order+1] = v
+end
+
rt.init(state, osd, ctx)
rx.init(state, osd, ctx)
@@ -216,6 +224,6 @@ input.activate(true)
mp.add_timeout(0, function()
rt.load_data()
state.depth = 0
- rt.push_group_menu(catalogue:get('root'))
+ rt.push_group_menu(ctx.catalogue:get('root'))
osd:redraw(state)
end)