diff options
| author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2025-12-20 15:21:09 -0800 |
|---|---|---|
| committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2025-12-20 15:21:09 -0800 |
| commit | 5b8d6951b91bfe6ce0da272e4623f9ba7eca2a57 (patch) | |
| tree | ae09b019a1ca16b1ec1909b2d19e70119e9594de /main.lua | |
| parent | eca95626c765f11d8fa1b7def0f6afa8fc0cd0d8 (diff) | |
| download | mpv-iptv-menu-5b8d6951b91bfe6ce0da272e4623f9ba7eca2a57.tar.gz mpv-iptv-menu-5b8d6951b91bfe6ce0da272e4623f9ba7eca2a57.tar.xz | |
use stale cache on failed refresh
Diffstat (limited to 'main.lua')
| -rw-r--r-- | main.lua | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -118,18 +118,21 @@ local function cached_xc_call(method) local path = mp_utils.join_path( script_dir, 'cache/' .. xc.server:gsub('%W', '_') .. '.' .. method) - local f = mp_utils.file_info(path) - if f and os.time() - f.mtime < 24*60*60 then - return util.read_json_file(path) + local data + + if not f or os.time() - f.mtime > 24*60*60 then + data = xc[method](xc) + if data then + util.write_json_file(path, data) + end end - local data = xc[method](xc) - if not data then - return + if f and not data then + print('using cached ' .. method) + data = util.read_json_file(path) end - util.write_json_file(path, data) return data end |
