diff options
| author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2026-02-03 22:42:26 -0800 |
|---|---|---|
| committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2026-02-03 22:42:26 -0800 |
| commit | 554e833b1a39ede9aef234449fc8992435f10751 (patch) | |
| tree | 3b5e7cf0077c6b758eafd76a97bfc81f5ba15145 /main.lua | |
| parent | 6cc548c27470b81114412f3ecd74380894eba72e (diff) | |
| download | mpv-iptv-menu-554e833b1a39ede9aef234449fc8992435f10751.tar.gz mpv-iptv-menu-554e833b1a39ede9aef234449fc8992435f10751.tar.xz | |
support multiple sources
Diffstat (limited to 'main.lua')
| -rw-r--r-- | main.lua | 66 |
1 files changed, 37 insertions, 29 deletions
@@ -16,32 +16,7 @@ local _xc = require('xc') local mp_utils = require('mp.utils') local state = _state.new() - local downloader = _downloader.new({limit = 5}) -local xc = _xc.new({ - server = config.xc_server, - user = config.xc_user, - pass = config.xc_pass, -}) -xc = cacher.wrap(xc, { - directory = config.cache_dir, - prefix = (xc.server:gsub('%W', '_')), - time = 24*60*60, - functions = { - get_live_categories = true, - get_live_streams = true, - get_vod_categories = true, - get_vod_streams = true, - get_vod_info = true, - get_series_categories = true, - get_series = true, - get_series_info = true, - get_epg = true, - }, -}) - -local catalogue = _catalogue.new() -local epg = _epg.new() local osd local function dl_img(url, path, cb) @@ -71,10 +46,43 @@ osd = _osd.new({ }) local ctx = { - catalogue = catalogue, - epg = epg, - xc = xc, + catalogue = _catalogue.new(), + src = {}, + src_order = {}, } +for _, v in ipairs(config.src_order) do + local src = config.src[v] + local xc = _xc.new({ + url = src.url, + user = src.user, + pass = src.pass, + }) + xc = cacher.wrap(xc, { + directory = config.cache_dir, + prefix = (xc.url:gsub('%W', '_')), + time = 24*60*60, + functions = { + get_live_categories = true, + get_live_streams = true, + get_vod_categories = true, + get_vod_streams = true, + get_vod_info = true, + get_series_categories = true, + get_series = true, + get_series_info = true, + get_epg = true, + }, + }) + + ctx.src[v] = { + id = v, + name = src.name, + xc = xc, + epg = _epg.new(), + } + ctx.src_order[#ctx.src_order+1] = v +end + rt.init(state, osd, ctx) rx.init(state, osd, ctx) @@ -216,6 +224,6 @@ input.activate(true) mp.add_timeout(0, function() rt.load_data() state.depth = 0 - rt.push_group_menu(catalogue:get('root')) + rt.push_group_menu(ctx.catalogue:get('root')) osd:redraw(state) end) |
