summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2026-01-18 00:15:19 -0800
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2026-01-18 00:15:19 -0800
commit7ffcfb63e9df580e3d6b713402fc6e827e82d697 (patch)
treeb5964225830374e25506b79bad5353ad123958f4
parentb3665cc09ea0363beafc05a867c057e5c122985a (diff)
downloadmpv-iptv-menu-7ffcfb63e9df580e3d6b713402fc6e827e82d697.tar.gz
mpv-iptv-menu-7ffcfb63e9df580e3d6b713402fc6e827e82d697.tar.xz
allow reloading data while running
-rw-r--r--cacher.lua3
-rw-r--r--main.lua16
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},