summaryrefslogtreecommitdiff
path: root/main.lua
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2025-12-22 15:49:21 -0800
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2025-12-22 15:49:21 -0800
commit3da22d33f4093017ebd0d451ac64b5deab7ca19f (patch)
tree3848f7c25fb2fdf7741b3aa794e228c87c1879f0 /main.lua
parent304637102a306608d930b92d9422a85415ff9199 (diff)
downloadmpv-iptv-menu-3da22d33f4093017ebd0d451ac64b5deab7ca19f.tar.gz
mpv-iptv-menu-3da22d33f4093017ebd0d451ac64b5deab7ca19f.tar.xz
add info menu for series
Diffstat (limited to 'main.lua')
-rw-r--r--main.lua45
1 files changed, 32 insertions, 13 deletions
diff --git a/main.lua b/main.lua
index 97faf62..f5bf09c 100644
--- a/main.lua
+++ b/main.lua
@@ -114,22 +114,25 @@ local function add_object(obj)
parent_children[#parent_children+1] = obj
end
-local function cached_xc_call(method)
- local path = mp_utils.join_path(
- script_dir,
- 'cache/' .. xc.server:gsub('%W', '_') .. '.' .. method)
+local function cached_xc_call(method, ...)
+ local id = xc.server:gsub('%W', '_') .. '.' .. method
+ if select('#', ...) ~= 0 then
+ id = id .. '.' .. table.concat({...}, '.')
+ end
+
+ local path = mp_utils.join_path(script_dir, 'cache/' .. id)
local f = mp_utils.file_info(path)
local data
if not f or os.time() - f.mtime > 24*60*60 then
- data = xc[method](xc)
+ data = xc[method](xc, ...)
if data then
util.write_json_file(path, data)
end
end
if f and not data then
- print('using cached ' .. method)
+ print('using cached ' .. id)
data = util.read_json_file(path)
end
@@ -707,7 +710,7 @@ local function favourites_group_menu_options(group)
end
local function series_group_menu_options(series)
- local info = xc:get_series_info(series.series_id)
+ local info = cached_xc_call('get_series_info', series.series_id)
if not info or not info.seasons then
return {}
end
@@ -942,7 +945,7 @@ local function open_option_epg(opt)
end
local function add_info_field(dst, k, v, fmt)
- if not v then
+ if not v or v == '' then
return
end
@@ -963,8 +966,7 @@ local function add_info_field(dst, k, v, fmt)
end
end
-local function open_option_movie_info(opt)
- local info = xc:get_vod_info(opt.stream_id)
+local function open_option_title_info(title, info)
if not info or not info.info then
return
end
@@ -976,9 +978,10 @@ local function open_option_movie_info(opt)
add_info_field(options, 'Directed by', info.director)
add_info_field(options, 'Starring', info.cast)
- if info.description then
+ local desc = info.description or info.plot
+ if desc then
options[#options+1] = {name = ' '}
- for _, v in ipairs(util.wrap(info.description, 80)) do
+ for _, v in ipairs(util.wrap(desc, 80)) do
options[#options+1] = {name = v}
end
end
@@ -1038,16 +1041,30 @@ local function open_option_movie_info(opt)
local m = {
options = options,
- title = 'Movie Info: ' .. opt.name,
+ title = title,
}
if info.cover_big and info.cover_big ~= '' then
m.img_url = info.cover_big
+ elseif info.cover and info.cover ~= '' then
+ m.img_url = info.cover
end
push_menu(m)
update_osd()
end
+local function open_option_movie_info(opt)
+ open_option_title_info(
+ 'Movie Info: ' .. opt.name,
+ cached_xc_call('get_vod_info', opt.stream_id))
+end
+
+local function open_option_series_info(opt)
+ open_option_title_info(
+ 'Series Info: ' .. opt.name,
+ cached_xc_call('get_series_info', opt.series_id))
+end
+
local function open_option_info()
local menu = menus[depth]
local opt = menu.options[menu.cursor]
@@ -1059,6 +1076,8 @@ local function open_option_info()
open_epg_programme(opt.programme)
elseif opt.epg_channel_id then
open_option_epg(opt)
+ elseif opt.group_type == 'series' then
+ open_option_series_info(opt)
elseif opt.stream_id and opt.stream_type == 'movie' then
open_option_movie_info(opt)
end