summaryrefslogtreecommitdiff
path: root/main.lua
diff options
context:
space:
mode:
Diffstat (limited to 'main.lua')
-rw-r--r--main.lua50
1 files changed, 39 insertions, 11 deletions
diff --git a/main.lua b/main.lua
index 7a6f51d..72bf710 100644
--- a/main.lua
+++ b/main.lua
@@ -104,16 +104,6 @@ local function update_osd()
col = '{\\c&H99DDFF&}'
end
- local id
- if opt.type == 'category' then
- id = opt.category_id
- else
- id = opt.stream_id
- end
- if favourites[opt.type .. ':' .. id] then
- icons = icons .. '{\\c&HFF00FF&&}★ '
- end
-
if opt.hl then
local buf = ''
local n = 0
@@ -135,6 +125,16 @@ local function update_osd()
icons = icons .. '{\\c&HFF6633&&}\226\143\186 '
end
+ local id
+ if opt.type == 'category' then
+ id = opt.category_id
+ else
+ id = opt.stream_id
+ end
+ if favourites[opt.type .. ':' .. id] then
+ icons = icons .. '{\\c&HFF00FF&&}★ '
+ end
+
if opt.path and #opt.path > 0 then
local path = '{\\c&H666666&&}'
for i = #opt.path, 1, -1 do
@@ -220,6 +220,21 @@ local function push_menu(t)
menus[depth] = menu
end
+local function favourites_menu_options()
+ local options = {}
+ for _, v in ipairs(categories) do
+ if favourites['category:' .. v.category_id] then
+ options[#options+1] = v
+ end
+ end
+ for _, v in ipairs(streams) do
+ if favourites['stream:' .. v.stream_id] then
+ options[#options+1] = v
+ end
+ end
+ return options
+end
+
local function category_menu_options(category_id)
local options = {}
for _, v in ipairs(categories) do
@@ -236,8 +251,15 @@ local function category_menu_options(category_id)
end
local function add_category_menu(category_id, category_name)
+ local options
+ if category_id == 'favourites' then
+ options = favourites_menu_options()
+ else
+ options = category_menu_options(category_id)
+ end
+
push_menu({
- options=category_menu_options(category_id),
+ options=options,
title=category_name,
})
update_osd()
@@ -557,4 +579,10 @@ end)
mp.add_forced_key_binding('TAB', 'toggle-menu', toggle_menu)
bind_menu_keys()
load_data()
+table.insert(categories, 1, {
+ name='Favourites',
+ type='category',
+ category_id='favourites',
+ parent_id=0,
+})
add_category_menu('0')