diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2025-05-06 23:11:24 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2025-05-06 23:11:24 -0700 |
commit | 7ac2ea605b5ef7d5bf2b6d54bb1125714de856a2 (patch) | |
tree | a202135ac84f5aedf4e70da4493160cd95feabaa | |
parent | 48f3b534ad804e8c954be0b2360f70dc03cb2a84 (diff) | |
download | mpv-iptv-menu-7ac2ea605b5ef7d5bf2b6d54bb1125714de856a2.tar.gz mpv-iptv-menu-7ac2ea605b5ef7d5bf2b6d54bb1125714de856a2.tar.xz |
prioritise categories in search results
-rw-r--r-- | main.lua | 32 |
1 files changed, 24 insertions, 8 deletions
@@ -152,8 +152,10 @@ local function push_menu(t) page_pos=1, } - for k, v in pairs(t) do - menu[k] = v + if t then + for k, v in pairs(t) do + menu[k] = v + end end depth = depth + 1 @@ -232,19 +234,33 @@ local function search_update_osd() update_osd() end -local function search_menu_options(options, arr) +local function search_menu_options_build(options, t) local menu = menus[depth] - local arr = arr or {} for _, v in ipairs(options) do - arr[#arr+1] = v + if not t[v.type] then + t[v.type] = {} + end + t[v.type][#t[v.type]+1] = v if v.type == 'category' then - search_menu_options( - category_menu_options(v.category_id), arr) + search_menu_options_build( + category_menu_options(v.category_id), t) + end + end +end + +local function search_menu_options(options) + local t = {} + search_menu_options_build(options, t) + + local ret = t.category or {} + if t.stream then + for _, v in ipairs(t.stream) do + ret[#ret+1] = v end end - return arr + return ret end local function search_update() |