From e1f7209131cafab74f0665599a13d668ebeb410c Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Fri, 6 Feb 2026 12:30:32 -0800 Subject: implement global EPG search --- rt.lua | 121 ++++++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 67 insertions(+), 54 deletions(-) (limited to 'rt.lua') diff --git a/rt.lua b/rt.lua index 8ed3dc9..4a90e6e 100644 --- a/rt.lua +++ b/rt.lua @@ -482,49 +482,6 @@ function rt.favourite_option() osd:dirty() end -function rt.goto_option() - local menu = state:menu() - local opt = menu.options[menu.cursor] - if not opt or not opt.path then - return - end - - if menu.group_id == 'favourites' then - state.depth = 1 - elseif menu.type == 'search' then - state.depth = state.depth - 1 - if state:menu().group_id == 'favourites' then - merge_refreshed_menu_options() - end - end - - for i = 1, #opt.path do - cursor_to_id(opt.path[i].id) - rt.push_group_menu(opt.path[i]) - end - cursor_to_id(opt.id) - - osd:dirty() -end - -function rt.goto_playing() - local id = state.playing_id - local obj = id and ctx.catalogue:get(id) - local path = obj and ctx.catalogue:path_to_root(obj) - if not path then - return - end - - state.depth = 1 - for i = #path, 1, -1 do - cursor_to_id(path[i].id) - rt.push_group_menu(path[i]) - end - cursor_to_id(id) - - osd:dirty() -end - local function open_option_programme_info(opt, img_url) local prog = opt.programme local options = rx.menu_options_programme_info(prog) @@ -621,6 +578,53 @@ function rt.open_option_info(opt) end end +function rt.goto_option() + local menu = state:menu() + local opt = menu.options[menu.cursor] + if not opt or not opt.path then + return + end + + if menu.group_id == 'favourites' then + state.depth = 1 + elseif menu.type == 'search' then + state.depth = state.depth - 1 + if state:menu().group_id == 'favourites' then + merge_refreshed_menu_options() + end + end + + for i = 1, #opt.path do + cursor_to_id(opt.path[i].id) + if i == #opt.path and opt.type == 'programme' then + open_option_channel_epg(opt.path[i]) + else + rt.push_group_menu(opt.path[i]) + end + end + cursor_to_id(opt.id) + + osd:dirty() +end + +function rt.goto_playing() + local id = state.playing_id + local obj = id and ctx.catalogue:get(id) + local path = obj and ctx.catalogue:path_to_root(obj) + if not path then + return + end + + state.depth = 1 + for i = #path, 1, -1 do + cursor_to_id(path[i].id) + rt.push_group_menu(path[i]) + end + cursor_to_id(id) + + osd:dirty() +end + local F_NAME = {name = true} local F_INFO = {info = true} local F_BOTH = {name = true, info = true} @@ -739,14 +743,12 @@ function rt.search_cursor_end() search_cursor_move(function(str) return #str + 1 end) end -function rt.start_search() +function rt.start_search(options, search_type, title) local menu = state:menu() - local title = 'Searching: ' .. - ' (/)' - - if menu.type == 'search' then + if menu.type == 'search' and + (not search_type or + menu.search_type == search_type) then menu:save_checkpoint() - menu.title = title menu.search_active = true menu:set_search_cursor(#menu.search_text + 1) menu:set_cursor(1) @@ -754,8 +756,10 @@ function rt.start_search() state:push_menu({ title = title, type = 'search', - options = rx.menu_options_search(menu.options), + options = options or + rx.menu_options_search(menu.options), search_active = true, + search_type = search_type, }) end @@ -763,11 +767,20 @@ function rt.start_search() input.set_mapping('SEARCH') end -function rt.end_search() +function rt.start_epg_search() local menu = state:menu() - menu.search_active = false - menu.title = 'Search results: ' .. - ' (/)' + local options = menu.search_type ~= 'epg' and + rx.menu_options_epg_search(menu.options) or nil + if options and not next(options) then + osd:flash_error('No EPG data found') + return + end + + rt.start_search(options, 'epg', 'EPG') +end + +function rt.end_search() + state:menu().search_active = false osd:dirty() input.set_mapping('MENU') end -- cgit v1.2.3-70-g09d2