From 7ffcfb63e9df580e3d6b713402fc6e827e82d697 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Sun, 18 Jan 2026 00:15:19 -0800 Subject: allow reloading data while running --- cacher.lua | 3 ++- main.lua | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/cacher.lua b/cacher.lua index ef5d3b1..70d7d2c 100644 --- a/cacher.lua +++ b/cacher.lua @@ -12,7 +12,8 @@ local function exec(obj, opts, call_opts, func, func_name, ...) local path = mp_utils.join_path(opts.directory, fn) local f = mp_utils.file_info(path) local data - local miss = not f or os.time() - f.mtime > opts.time + local miss = call_opts.force or not f or + os.time() - f.mtime > opts.time if miss then if call_opts.before_miss then diff --git a/main.lua b/main.lua index 64b2e0d..19875f0 100644 --- a/main.lua +++ b/main.lua @@ -89,7 +89,7 @@ local function set_key_mapping(m) binding_state.active = binding_state.mappings[m] end -local function load_data() +local function load_data(force) local arr = { {id = 'live', name = 'Live TV', type = 'live'}, {id = 'movie', name = 'Movies', type = 'vod'}, @@ -100,6 +100,7 @@ local function load_data() local sect_str local disp_str local call_opts = { + force = not not force, before_hit = function() if disp_str ~= base_str and disp_str ~= sect_str then osd:set_status(base_str .. '...') @@ -1122,10 +1123,23 @@ local function mouse_click_right(ev) open_option_info(menu.options[pos]) end +local function reload_data() + if state.depth > 1 then + osd:flash_error('Can only reload data from root menu') + return + end + + catalogue = _catalogue.new() + load_data(true) + state.depth = 0 + push_group_menu(catalogue:get('root')) +end + binding_state.mappings.MENU = { ['BS'] = {prev_menu}, ['/'] = {start_search}, ['Ctrl+s'] = {toggle_menu_sort}, + ['Ctrl+R'] = {reload_data}, ['ENTER'] = {select_option}, ['Ctrl+f'] = {favourite_option}, -- cgit v1.2.3-70-g09d2