summaryrefslogtreecommitdiff
path: root/xc.lua
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2025-12-19 16:54:46 -0800
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2025-12-19 16:54:46 -0800
commita774d41fdfd333fa0dd7ac1c558febe15638ea16 (patch)
tree6504d3261d820d552094b728caedf653e3768948 /xc.lua
parent48fcfe19baae31c2e1635c911f7383d6d58d2aa1 (diff)
downloadmpv-iptv-menu-a774d41fdfd333fa0dd7ac1c558febe15638ea16.tar.gz
mpv-iptv-menu-a774d41fdfd333fa0dd7ac1c558febe15638ea16.tar.xz
request categories and streams from API
Diffstat (limited to 'xc.lua')
-rw-r--r--xc.lua49
1 files changed, 39 insertions, 10 deletions
diff --git a/xc.lua b/xc.lua
index c7f311e..a934e42 100644
--- a/xc.lua
+++ b/xc.lua
@@ -15,28 +15,57 @@ function xc.new(t)
end
function mt:get(params)
- local cmd = 'curl -sSfL \'' .. self.server .. '/player_api.php' ..
+ local url = self.server .. '/player_api.php' ..
'?username=' .. self.user .. '&password=' .. self.pass
for k, v in pairs(params) do
- cmd = cmd .. '&' .. k .. '=' .. v
+ url = url .. '&' .. k .. '=' .. v
end
- cmd = cmd .. '\''
+ local cmd = {'curl', '-sSfL', url}
+ print('querying ' .. url)
- print('exec: ' .. cmd)
- local fd = io.popen(cmd)
- local json = fd:read('*all')
- fd:close()
- return mp_utils.parse_json(json)
+ local res = mp.command_native({
+ name = 'subprocess',
+ args = cmd,
+ capture_stdout = true,
+ playback_only = false,
+ })
+ if res.status == 0 then
+ return mp_utils.parse_json(res.stdout)
+ end
end
-function mt:get_series_info(id)
- return self:get({action = 'get_series_info', series_id = id})
+function mt:get_live_categories()
+ return self:get({action = 'get_live_categories'})
+end
+
+function mt:get_live_streams()
+ return self:get({action = 'get_live_streams'})
+end
+
+function mt:get_vod_categories()
+ return self:get({action = 'get_vod_categories'})
+end
+
+function mt:get_vod_streams()
+ return self:get({action = 'get_vod_streams'})
end
function mt:get_vod_info(id)
return self:get({action = 'get_vod_info', vod_id = id})
end
+function mt:get_series_categories()
+ return self:get({action = 'get_series_categories'})
+end
+
+function mt:get_series()
+ return self:get({action = 'get_series'})
+end
+
+function mt:get_series_info(id)
+ return self:get({action = 'get_series_info', series_id = id})
+end
+
function mt:stream_url(stream_type, stream_id)
if stream_type == 'series' then
return self.server .. '/series/' ..