diff options
| author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2026-02-06 12:30:32 -0800 |
|---|---|---|
| committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2026-02-06 12:30:32 -0800 |
| commit | e1f7209131cafab74f0665599a13d668ebeb410c (patch) | |
| tree | 33d7d8c0beb9d91a5bd7ab5b51d4e1389ce97794 /rx.lua | |
| parent | ef41e8c9a54119628aa8cffb193e42782e69563f (diff) | |
| download | mpv-iptv-menu-e1f7209131cafab74f0665599a13d668ebeb410c.tar.gz mpv-iptv-menu-e1f7209131cafab74f0665599a13d668ebeb410c.tar.xz | |
implement global EPG search
Diffstat (limited to 'rx.lua')
| -rw-r--r-- | rx.lua | 59 |
1 files changed, 59 insertions, 0 deletions
@@ -281,6 +281,7 @@ function rx.menu_options_channel_epg(src_id, ch) local time = os.time() for i, v in ipairs(progs) do local prog = { + id = ch .. ':' .. i, name = os.date('%a %d %b %H:%M', v.start) .. ' ' .. os.date('%H:%M', v.stop) .. ' ' .. v.title, type = 'programme', @@ -315,6 +316,64 @@ function rx.menu_options_programme_info(prog) return options end +local function menu_options_epg_search_build_progs(options, opt, path, time) + local ch = opt.epg_channel_id + local progs = ctx.src[opt.src_id].epg:channel_programmes(ch) + if not progs then + return + end + + for i, v in ipairs(progs) do + if time < v.stop then + options[#options+1] = setmetatable({ + id = ch .. ':' .. i, + name = os.date('%a %d %b %H:%M', v.start) .. + ' ' .. os.date('%H:%M', v.stop) .. + ' ' .. v.title, + type = 'programme', + programme = v, + path = path, + }, programme_mt) + end + end +end + +local function menu_options_epg_search_build(options, opts, path, seen, time) + for _, v in ipairs(opts) do + if v.id and not seen[v.id] then + seen[v.id] = true + path[#path+1] = v + if v.epg_channel_id then + menu_options_epg_search_build_progs( + options, v, util.copy_table(path), + time) + elseif v.type == 'group' and v.children then + menu_options_epg_search_build( + options, v.children, path, seen, time) + end + path[#path] = nil + end + end +end + +function rx.menu_options_epg_search(opts) + local options = {} + local time = os.time() + + menu_options_epg_search_build(options, opts, {}, {}, time) + table.sort(options, function(a, b) + if a.programme.start ~= b.programme.start then + return a.programme.start < b.programme.start + end + if a.programme.title ~= b.programme.title then + return a.programme.title < b.programme.title + end + return a.path[#a.path].name < b.path[#b.path].name + end) + + return options +end + local function menu_options_search_build(options, t, path) for _, v in ipairs(options) do v.path = path |
