summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2026-02-06 14:04:11 -0800
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2026-02-06 14:04:11 -0800
commit1d93ccb330dca438322a0438b79eea718c4cf73b (patch)
tree45c257db05c480a05e2deb601af7b7c3fec128be
parente1f7209131cafab74f0665599a13d668ebeb410c (diff)
downloadmpv-iptv-menu-1d93ccb330dca438322a0438b79eea718c4cf73b.tar.gz
mpv-iptv-menu-1d93ccb330dca438322a0438b79eea718c4cf73b.tar.xz
common goto path function
-rw-r--r--rt.lua40
1 files changed, 22 insertions, 18 deletions
diff --git a/rt.lua b/rt.lua
index 4a90e6e..73b5b9d 100644
--- a/rt.lua
+++ b/rt.lua
@@ -578,6 +578,24 @@ function rt.open_option_info(opt)
end
end
+local function goto_path(path, opt, reverse)
+ local start, stop, step = 1, #path, 1
+ if reverse then
+ start, stop, step = stop, start, -1
+ end
+
+ for i = start, stop, step do
+ cursor_to_id(path[i].id)
+ if i == stop and opt.type == 'programme' then
+ open_option_channel_epg(path[i])
+ else
+ rt.push_group_menu(path[i])
+ end
+ end
+
+ cursor_to_id(opt.id)
+end
+
function rt.goto_option()
local menu = state:menu()
local opt = menu.options[menu.cursor]
@@ -594,34 +612,20 @@ function rt.goto_option()
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)
-
+ goto_path(opt.path, opt)
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)
+ local opt = id and ctx.catalogue:get(id)
+ local path = opt and ctx.catalogue:path_to_root(opt)
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)
-
+ goto_path(path, opt, true)
osd:dirty()
end