summaryrefslogtreecommitdiff
path: root/main.lua
diff options
context:
space:
mode:
Diffstat (limited to 'main.lua')
-rw-r--r--main.lua22
1 files changed, 17 insertions, 5 deletions
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)