From b3665cc09ea0363beafc05a867c057e5c122985a Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Sun, 18 Jan 2026 00:00:24 -0800 Subject: support timed status/error messages To support this, render() has been pulled out of redraw(), allowing updating the actual OSD without having to pass in the 'state' object, avoiding complexity and unnecessary computation. --- main.lua | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'main.lua') diff --git a/main.lua b/main.lua index 7c572f5..64b2e0d 100644 --- a/main.lua +++ b/main.lua @@ -13,7 +13,6 @@ local _xc = require('xc') local mp_utils = require('mp.utils') local script_name = mp.get_script_name() -local script_dir = mp.get_script_directory() local state = _state.new() local binding_state = {mappings = {}, active = {}} @@ -45,19 +44,32 @@ xc = cacher.wrap(xc, { local catalogue = _catalogue.new() local epg = _epg.new() -local osd = _osd.new({ + +local osd +local function dl_img(url, path, cb) + downloader:schedule(url, path, function(success, _, path) + if success then + cb(path) + else + osd:flash_error('Image download failed') + end + end) + +end +osd = _osd.new({ img_path_func = function(url, cb) local path = mp_utils.join_path( config.img_dir, url:gsub('%W', '_')) if not mp_utils.file_info(path) and cb then - downloader:schedule(url, path, function(_, path) - cb(path) - end) + dl_img(url, path, cb) end return path end, + img_fail_cb = function() + osd:flash_error('Image load failed') + end }) local function cache_miss_status_msg(str) -- cgit v1.2.3-70-g09d2