summaryrefslogtreecommitdiff
path: root/main.lua
diff options
context:
space:
mode:
Diffstat (limited to 'main.lua')
-rw-r--r--main.lua62
1 files changed, 47 insertions, 15 deletions
diff --git a/main.lua b/main.lua
index 015b43d..130f387 100644
--- a/main.lua
+++ b/main.lua
@@ -143,7 +143,8 @@ local function add_object(obj)
group_type='category',
id=obj.parent_id,
parent_id=obj.section .. ':category:0',
- name='*CATCHALL*',
+ -- non-ascii symbol to sort near end
+ name='🞷CATCHALL🞷',
})
end
end
@@ -456,13 +457,6 @@ local function cursor_to_object(id)
end
end
-local function prev_menu()
- if depth > 1 then
- depth = depth - 1
- update_osd()
- end
-end
-
local function push_menu(t)
local menu = {
options={},
@@ -541,12 +535,21 @@ local function add_programme(opt, time)
if opt.epg_channel_id then
local prog = epg_programme(opt.epg_channel_id, time)
if prog then
- opt = copy_table(opt)
opt.info = asscape(prog.title)
end
end
+end
- return opt
+local function count_group_children(group)
+ if group.children and not group.lazy then
+ return tostring(#group.children)
+ elseif group.id == 'favourites' then
+ local c = 0
+ for _ in pairs(favourites) do
+ c = c + 1
+ end
+ return tostring(c - 1) -- remove dummy value
+ end
end
local function favourites_group_menu_options(group)
@@ -562,13 +565,25 @@ local function favourites_group_menu_options(group)
curr = objects[curr.parent_id]
path[#path+1] = curr
end
+
+ obj = copy_table(obj)
+ add_programme(obj, time)
+ local c = count_group_children(obj)
+ if c then
+ obj.info = c
+ end
if #path > 0 and curr.parent_id == 'root' then
reverse(path)
- obj = copy_table(obj)
obj.path = path
end
-
- options[#options+1] = add_programme(obj, time)
+ options[#options+1] = obj
+ elseif id ~= 'oi' then -- ignore dummy value
+ -- display missing favourites so that they can be
+ -- removed
+ options[#options+1] = {
+ id=id,
+ name='🞷MISSING🞷 ' .. id,
+ }
end
end
return options
@@ -633,7 +648,13 @@ local function group_menu_options(group)
local options = {}
local time = os.time()
for i, v in ipairs(group.children) do
- options[i] = add_programme(v, time)
+ v = copy_table(v)
+ add_programme(v, time)
+ local c = count_group_children(v)
+ if c then
+ v.info = c
+ end
+ options[i] = v
end
return options
end
@@ -648,6 +669,17 @@ local function push_group_menu(group)
update_osd()
end
+local function prev_menu()
+ depth = depth - 1
+
+ if depth == 0 then
+ -- reset main menu
+ push_group_menu(objects[menus[1].group_id])
+ else
+ update_osd()
+ end
+end
+
local function play_stream(stream)
-- add a per-file option containing the stream id, allowing it to be
-- retrieved when a start-file event is received
@@ -673,7 +705,7 @@ local function select_option()
if opt.type == 'group' then
push_group_menu(opt)
- else
+ elseif opt.type == 'stream' then
play_stream(opt)
end
end