diff options
| -rw-r--r-- | main.lua | 3 | ||||
| -rw-r--r-- | osd.lua | 2 | ||||
| -rw-r--r-- | rt.lua | 26 |
3 files changed, 13 insertions, 18 deletions
@@ -14,10 +14,7 @@ local _xc = require('xc') local mp_utils = require('mp.utils') -local script_name = mp.get_script_name() - local state = _state.new() -local click_state = {} local downloader = _downloader.new({limit = 5}) local xc = _xc.new({ @@ -12,7 +12,7 @@ local colour = {} for k, v in pairs(config.colour) do -- constructed backwards as ASS colour tags expect BGR but we configure -- them as RGB - tag = '&}' + local tag = '&}' for byte in v:gmatch('..') do tag = byte:upper() .. tag end @@ -388,17 +388,6 @@ local function sort_options(options) end) end -local function add_programme(opt, time) - if opt.epg_channel_id then - local prog = ctx.epg:scheduled_programme( - opt.epg_channel_id, time) - if prog then - opt.info = prog.title - end - end -end - -local menu_option_mt_count = 0 local menu_option_mt = { __index = function(t, k) local v = t._v @@ -653,6 +642,16 @@ local function open_epg_programme(prog, img_url) osd:dirty() end +local epg_programme_mt = { + __index = function(t, k) + if k == 'active' then + local time = osd.redraw_time + local v = t.programme + return time >= v.start and time < v.stop + end + end, +} + local function open_option_epg(opt) local ch = opt.epg_channel_id:lower() local progs = ctx.epg:channel_programmes(ch) @@ -664,7 +663,7 @@ local function open_option_epg(opt) local curr = 0 local time = os.time() for i, v in ipairs(progs) do - prog = { + local prog = { name = os.date('%a %d %b %H:%M', v.start) .. ' ' .. os.date('%H:%M', v.stop) .. ' ' .. v.title, info = v.desc, @@ -673,10 +672,9 @@ local function open_option_epg(opt) if curr == 0 and time >= v.start and time < v.stop then curr = i - prog.active = true end - options[i] = prog + options[i] = setmetatable(prog, epg_programme_mt) end local menu = state:push_menu({ |
