summaryrefslogtreecommitdiff
path: root/xc.lua
diff options
context:
space:
mode:
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/' ..