diff options
| author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2026-01-14 00:27:08 -0800 |
|---|---|---|
| committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2026-01-14 00:27:08 -0800 |
| commit | 671e5934a9400b722210d4d243dd83c0755a4fa3 (patch) | |
| tree | bd267d3b3b89a670dd6eea9620dd75accb411830 | |
| parent | 16911601f7da38191c5c1fe900d615f8b860ca52 (diff) | |
| download | mpv-iptv-menu-671e5934a9400b722210d4d243dd83c0755a4fa3.tar.gz mpv-iptv-menu-671e5934a9400b722210d4d243dd83c0755a4fa3.tar.xz | |
add status line; load data after mpv opens
| -rw-r--r-- | config.lua | 2 | ||||
| -rw-r--r-- | main.lua | 39 | ||||
| -rw-r--r-- | osd.lua | 19 |
3 files changed, 51 insertions, 9 deletions
@@ -33,6 +33,8 @@ config.colours = { icon_missing = 'ff0000', scrollbar_fg = '666666', scrollbar_bg = '333333', + status_info = '55bbdd', + status_error = 'ff3333', } local script_dir = mp.get_script_directory() @@ -73,6 +73,8 @@ local function set_key_mapping(m) end local function load_data() + osd:set_status('Loading catalogue...') + update_osd() local arr = { {id = 'live', name = 'Live TV', type = 'live'}, {id = 'movie', name = 'Movies', type = 'vod'}, @@ -86,8 +88,13 @@ local function load_data() end catalogue:load_xc_data(arr) + osd:set_status('Loading EPG...') + update_osd() epg:load_xc_data(xc:get_epg()) + osd:set_status() + update_osd() + local t = util.read_json_file(config.favourites_file) state.favourites = t.favourites or {} end @@ -292,7 +299,11 @@ local function favourites_group_menu_options(group) end local function series_group_menu_options(series) + osd:set_status('Loading series info...') + update_osd() local info = xc:get_series_info(series.series_id) + osd:set_status() + update_osd() if not info or not info.seasons then return {} end @@ -735,15 +746,21 @@ local function open_option_title_info(title, info) end local function open_option_movie_info(opt) - open_option_title_info( - 'Movie Info: ' .. opt.name, - xc:get_vod_info(opt.stream_id)) + osd:set_status('Loading movie info...') + update_osd() + local data = xc:get_vod_info(opt.stream_id) + osd:set_status() + update_osd() + open_option_title_info('Movie Info: ' .. opt.name, data) end local function open_option_series_info(opt) - open_option_title_info( - 'Series Info: ' .. opt.name, - xc:get_series_info(opt.series_id)) + osd:set_status('Loading series info...') + update_osd() + local data = xc:get_series_info(opt.series_id) + osd:set_status() + update_osd() + open_option_title_info('Series Info: ' .. opt.name, data) end local function open_option_season_info(opt) @@ -1238,8 +1255,7 @@ mp.register_event('end-file', function() update_osd() end) -load_data() -push_group_menu(catalogue:get('root')) +state:push_menu({title = 'mpv-iptv-menu'}) osc_visibility = mp.get_property_native('user-data/osc/visibility', 'auto') set_osc_visibility() @@ -1247,3 +1263,10 @@ set_osc_visibility() mp.add_forced_key_binding('TAB', 'toggle-menu', toggle_menu) set_key_mapping('MENU') set_key_bindings() + +mp.add_timeout(0, function() + load_data() + state.depth = 0 + push_group_menu(catalogue:get('root')) + update_osd() +end) @@ -60,6 +60,21 @@ function mt:resize(w, h) self.scale = h / 720 end +function mt:set_status(msg, level) + self.status_msg = msg + self.status_level = level +end + +function mt:status_line() + if not self.status_msg then + return '' + end + + local col = self.status_level == 'error' and colours.status_error or + colours.status_info + return col .. '🞸 {\\i1}' .. asscape(self.status_msg) +end + function mt:menu_lines(state) -- leaves an extra line for padding between titles and options return self.lines - state.depth - 1 @@ -363,7 +378,9 @@ function mt:redraw(state) for i = 1, state.depth do out[#out+1] = self:menu_title(state.menus[i]) end - out[#out+1] = '' + + -- use spacer line between titles and options for status messages + out[#out+1] = self:status_line() local menu = state:menu() |
