diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2025-05-15 20:20:28 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2025-05-15 20:20:28 -0700 |
commit | 11924e092e6b7dce6ed40a31ca11ad55dfe0358a (patch) | |
tree | 07f0b674b2d2c4f6d746f7f403b3fe02dd528aab | |
parent | 0a67a421c0117459e257193383086228d731b644 (diff) | |
download | mpv-iptv-menu-11924e092e6b7dce6ed40a31ca11ad55dfe0358a.tar.gz mpv-iptv-menu-11924e092e6b7dce6ed40a31ca11ad55dfe0358a.tar.xz |
display more useful counts
-rw-r--r-- | main.lua | 39 |
1 files changed, 29 insertions, 10 deletions
@@ -540,15 +540,29 @@ local function add_programme(opt, time) end end -local function count_group_children(group) +local function group_count(group) if group.children and not group.lazy then - return tostring(#group.children) + local count = 0 + for _, v in ipairs(group.children) do + if v.type == 'stream' or v.group_type == 'series' then + count = count + 1 + elseif v.type == 'group' then + local c = group_count(v) + if c then + count = count + c + end + end + end + return count elseif group.id == 'favourites' then - local c = 0 - for _ in pairs(favourites) do - c = c + 1 + -- count number of favourited items, not recursive + local count = 0 + for k in pairs(favourites) do + if k ~= 'oi' then + count = count + 1 + end end - return tostring(c - 1) -- remove dummy value + return count end end @@ -568,9 +582,9 @@ local function favourites_group_menu_options(group) obj = copy_table(obj) add_programme(obj, time) - local c = count_group_children(obj) + local c = group_count(obj) if c then - obj.info = c + obj.info = tostring(c) end if #path > 0 and curr.parent_id == 'root' then reverse(path) @@ -624,12 +638,17 @@ local function series_group_menu_options(series) end end + local count = tostring(#episodes) + if season.episode_count then + count = count .. '/' .. season.episode_count + end seasons[#seasons+1] = { type='group', group_type='season', id=series.section .. 'series:season:' .. season.id, children=episodes, name=strip(season.name), + info=count, } end @@ -650,9 +669,9 @@ local function group_menu_options(group) for i, v in ipairs(group.children) do v = copy_table(v) add_programme(v, time) - local c = count_group_children(v) + local c = group_count(v) if c then - v.info = c + v.info = tostring(c) end options[i] = v end |