diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2025-05-12 21:35:51 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2025-05-12 21:35:51 -0700 |
commit | d8a57993b184e378742947adeef382572775ef80 (patch) | |
tree | 8b822a6de1a0bde587910bc67f3855167bd928fe | |
parent | e283d573c927d2b3551e7f0d4cf501f41d524ccf (diff) | |
download | mpv-iptv-menu-d8a57993b184e378742947adeef382572775ef80.tar.gz mpv-iptv-menu-d8a57993b184e378742947adeef382572775ef80.tar.xz |
add paths to favourites
-rw-r--r-- | main.lua | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -53,6 +53,12 @@ local function copy_table(t) return u end +local function reverse(t) + for i = 1, #t/2 do + t[i], t[#t-i+1] = t[#t-i+1], t[i] + end +end + local function strip(str) return (str:gsub('^%s*(.-)%s*$', '%1')) end @@ -387,6 +393,19 @@ local function favourites_group_menu_options(group) for id in pairs(favourites) do local obj = objects[id] if obj then + local path = {} + local curr = obj + while curr.parent_id and curr.parent_id ~= 'root' and + objects[curr.parent_id] do + curr = objects[curr.parent_id] + path[#path+1] = curr + end + if #path > 0 and curr.parent_id == 'root' then + reverse(path) + obj = copy_table(obj) + obj.path = path + end + options[#options+1] = obj end end |