diff options
| author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2026-01-27 01:20:08 -0800 |
|---|---|---|
| committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2026-01-22 16:49:34 -0800 |
| commit | 7f98c343879b2d578e5c7096a118f51882a4ea8e (patch) | |
| tree | e807527514b047b9dac815400c379d550a83648d | |
| parent | e985711d6dbd25833eb4069142b0788c1b943c36 (diff) | |
| download | mpv-iptv-menu-7f98c343879b2d578e5c7096a118f51882a4ea8e.tar.gz mpv-iptv-menu-7f98c343879b2d578e5c7096a118f51882a4ea8e.tar.xz | |
add caching to EPG metatable
| -rw-r--r-- | rt.lua | 31 |
1 files changed, 16 insertions, 15 deletions
@@ -401,32 +401,24 @@ local menu_option_mt = { end return ret elseif v.epg_channel_id then - if t._info_exp and - osd.redraw_time < - t._info_exp then + local time = osd.redraw_time + if t._exp and time < t._exp then return t._info end local prog = ctx.epg:scheduled_programme( - v.epg_channel_id, - osd.redraw_time) + v.epg_channel_id, time) local ret = prog and prog.title or '' local exp = prog and prog.stop if not prog then prog = ctx.epg:next_programme( - v.epg_channel_id, - osd.redraw_time) + v.epg_channel_id, time) exp = prog and prog.start - - if not prog then - rawset(t, 'info', ret) - return ret - end end - rawset(t, '_info_exp', exp) - rawset(t, '_info', ret) + rawset(t, exp and '_info' or 'info', ret) + rawset(t, '_exp', exp) return ret end end @@ -646,8 +638,17 @@ local epg_programme_mt = { __index = function(t, k) if k == 'active' then local time = osd.redraw_time + if t._exp and time < t._exp then + return t._active + end + local v = t.programme - return time >= v.start and time < v.stop + local ret = time >= v.start and time < v.stop + local exp = time < v.start and v.start or + ret and v.stop or nil + rawset(t, exp and '_active' or 'active', ret) + rawset(t, '_exp', exp) + return ret end end, } |
