summaryrefslogtreecommitdiff
path: root/rt.lua
diff options
context:
space:
mode:
Diffstat (limited to 'rt.lua')
-rw-r--r--rt.lua115
1 files changed, 67 insertions, 48 deletions
diff --git a/rt.lua b/rt.lua
index 6b2c09d..c234415 100644
--- a/rt.lua
+++ b/rt.lua
@@ -4,6 +4,7 @@ local config = require('config')
local input = require('input')
local rx = require('rx')
local util = require('util')
+local _catalogue = require('catalogue')
local rt = {}
@@ -33,16 +34,18 @@ end
local function series_children(series)
return rx.series_children(
series,
- ctx.xc:with_opts('get_series_info', series.series_id,
+ ctx.src[series.src_id].xc:with_opts(
+ 'get_series_info', series.series_id,
cache_miss_status_msg('Loading series info...')))
end
-local function catalogue_add_section(sect, cats, elems)
+local function catalogue_add_section(src_id, sect, cats, elems)
ctx.catalogue:add({
+ src_id = src_id,
section = sect.id,
type = 'group',
- group_type = 'category',
- id = sect.id .. ':category:0',
+ group_type = 'cat',
+ id = src_id .. ':' .. sect.id .. ':cat:0',
parent_id = 'root',
name = sect.name,
})
@@ -51,26 +54,32 @@ local function catalogue_add_section(sect, cats, elems)
-- before their parent category
for _, v in ipairs(cats) do
ctx.catalogue:add({
+ src_id = src_id,
section = sect.id,
type = 'group',
- group_type = 'category',
- id = sect.id .. ':category:' .. v.category_id,
- parent_id = sect.id .. ':category:' .. v.parent_id,
+ group_type = 'cat',
+ id = src_id .. ':' .. sect.id .. ':cat:' ..
+ v.category_id,
+ parent_id = src_id .. ':' .. sect.id .. ':cat:' ..
+ v.parent_id,
name = util.strip(v.category_name),
})
end
for _, v in ipairs(elems) do
local vv = {
+ src_id = src_id,
section = sect.id,
- parent_id = sect.id .. ':category:' .. v.category_id,
+ parent_id = src_id .. ':' .. sect.id .. ':cat:' ..
+ v.category_id,
name = util.strip(v.name),
}
if sect.type == 'series' then
vv.type = 'group'
vv.group_type = 'series'
- vv.id = sect.id .. ':series:' .. v.series_id
+ vv.id = src_id .. ':' .. sect.id .. ':series:' ..
+ v.series_id
vv.series_id = v.series_id
vv.img_url = util.strip_ne(v.cover)
vv.count = 1
@@ -78,7 +87,8 @@ local function catalogue_add_section(sect, cats, elems)
vv.children_f = series_children
else
vv.type = 'stream'
- vv.id = sect.id .. ':stream:' .. v.stream_id
+ vv.id = src_id .. ':' .. sect.id .. ':stream:' ..
+ v.stream_id
vv.stream_type = v.stream_type
vv.stream_id = v.stream_id
vv.img_url = util.strip_ne(v.stream_icon)
@@ -89,35 +99,12 @@ local function catalogue_add_section(sect, cats, elems)
end
end
-function rt.load_data(force)
- ctx.catalogue:add({
- type = 'group',
- id = 'favourites',
- parent_id = 'root',
- name = 'Favourites',
- count_f = function()
- return #state.favourites
- end,
- children_f = function()
- local options = {}
- for i, id in ipairs(state.favourites) do
- -- missing favourites are displayed so that
- -- they can be removed
- options[i] = ctx.catalogue:get(id) or
- {
- id = id,
- name = id,
- missing = true,
- }
- end
- return options
- end,
- })
-
+function rt.load_data_src(src, force)
+ local pre = src.name and src.name .. ' | ' or ''
local arr = {
- {id = 'live', name = 'Live TV', type = 'live'},
- {id = 'movie', name = 'Movies', type = 'vod'},
- {id = 'series', name = 'Series', type = 'series'},
+ {id = 'live', name = pre .. 'Channels', type = 'live'},
+ {id = 'movie', name = pre .. 'Movies', type = 'vod'},
+ {id = 'series', name = pre .. 'Series', type = 'series'},
}
local base_str = 'Loading catalogue'
@@ -142,20 +129,50 @@ function rt.load_data(force)
}
for _, sect in ipairs(arr) do
sect_str = base_str .. ' ยป ' .. sect.name
- local cats = ctx.xc:with_opts(
+ local cats = src.xc:with_opts(
'get_' .. sect.type .. '_categories', call_opts)
- local elems = ctx.xc:with_opts(
+ local elems = src.xc:with_opts(
sect.type == 'series' and 'get_series' or
('get_' .. sect.type .. '_streams'),
call_opts)
- catalogue_add_section(sect, cats, elems)
+ catalogue_add_section(src.id, sect, cats, elems)
end
osd:set_status('Loading EPG...')
osd:redraw(state)
- ctx.epg:load_xc_data(
- ctx.xc:with_opts('get_epg', {force = not not force}))
+ src.epg:load_xc_data(
+ src.xc:with_opts('get_epg', {force = not not force}))
osd:set_status()
+end
+
+function rt.load_data(force)
+ ctx.catalogue:add({
+ type = 'group',
+ id = 'favourites',
+ parent_id = 'root',
+ name = 'Favourites',
+ count_f = function()
+ return #state.favourites
+ end,
+ children_f = function()
+ local options = {}
+ for i, id in ipairs(state.favourites) do
+ -- missing favourites are displayed so that
+ -- they can be removed
+ options[i] = ctx.catalogue:get(id) or
+ {
+ id = id,
+ name = id,
+ missing = true,
+ }
+ end
+ return options
+ end,
+ })
+
+ for _, v in ipairs(ctx.src_order) do
+ rt.load_data_src(ctx.src[v], force)
+ end
local t = util.read_json_file(config.favourites_file)
state.favourites = t.favourites or {}
@@ -352,7 +369,8 @@ end
local function play_stream(stream)
local url = stream.stream_url or
- ctx.xc:stream_url(stream.stream_type, stream.stream_id)
+ ctx.src[stream.src_id].xc:stream_url(
+ stream.stream_type, stream.stream_id)
if not url then
return
end
@@ -459,7 +477,7 @@ end
local function open_option_channel_epg(opt)
local ch = opt.epg_channel_id:lower()
- local options, idx = rx.menu_options_channel_epg(ch)
+ local options, idx = rx.menu_options_channel_epg(opt.src_id, ch)
if not options then
return
end
@@ -490,13 +508,15 @@ local function open_option_entry_info(title, info)
end
local function open_option_movie_info(opt)
- local info = ctx.xc:with_opts('get_vod_info', opt.stream_id,
+ local info = ctx.src[opt.src_id].xc:with_opts(
+ 'get_vod_info', opt.stream_id,
cache_miss_status_msg('Loading movie info...'))
open_option_entry_info('Movie Info: ' .. opt.name, info)
end
local function open_option_series_info(opt)
- local info = ctx.xc:with_opts('get_series_info', opt.series_id,
+ local info = ctx.src[opt.src_id].xc:with_opts(
+ 'get_series_info', opt.series_id,
cache_miss_status_msg('Loading series info...'))
open_option_entry_info('Series Info: ' .. opt.name, info)
end
@@ -661,7 +681,6 @@ function rt.cancel_search()
return
end
- menu.search_active = false
state.depth = state.depth - 1
osd:dirty()
input.set_mapping('MENU')