最近更新时间:2018-06-26 16:09:26
git clone https://github.com/KscSDK/ksc-sdk-python.git
cd ksc-sdk-python
python setup.py install
pip install ksc-sdk-python
所在位置: '/etc/kscore.cfg' 或 './.kscore.cfg'
注意: 使用相对路径时,需与运行目录保持一致
- ks_access_key_id和ks_secret_access_key是金山云控制台身份与管理里面生成密钥对
[Credentials]
ks_access_key_id='xxxxxxxxxxxxxxxxxxxx'
ks_secret_access_key='xxxxxxxxxxxxxxxxxxxxxxx'
from kscore.ket import getKetClient
第一种:
client = getKetClient("ket", "cn‐beijing‐6",use_ssl=False)
参数说明:
service_name: 服务名,填写"ket"
region_name: 区域名,填写"cn‐beijing‐6"
use_ssl: 是否https访问,填写False
第二种:
没有配置kscore.cfg调用方式
ks_access_key_id='xxxxxxxxxxxxxxxxxxxx'
ks_secret_access_key='xxxxxxxxxxxxxxxxxxxxxxx'
参数:服务service_name,大区region_name
client = getKetClient("ket", "cn-beijing-6",use_ssl=False,ks_access_key_id=ks_access_key_id,ks_secret_access_key=ks_secret_access_key)
适用于2.6、2.7、3.3、3.4的Python版本
Preset 创建模板
DelPreset 删除模板
GetPresetList 查询模板列表
GetPresetDetail 查询模板详情
GetStreamTranList 获取任务列表
StartStreamPull 发起外网拉流
StopStreamPull 停止外网拉流
StartLoop 发起轮播
StopLoop 停止轮播
UpdateLoop 更新轮播时长
GetLoopList 获取轮播列表
GetQuotaUsed 获取配额使用数据
CreateDirectorTask 创建选流任务
UpdateDirectorTask 更新选流任务
QueryDirectorTask 查询选流任务
注:接口的传递的参数及返回值请参考《视频云直播转码接入说明》API接口说明
接口名: Preset/UpdatePreset
- 调用方式
presetParam = {
"UniqName":"test",
"Preset":presetname,
"App":app,
"Description":description,
"Output":[
{
"format":{
"output_format":256,
"abr": 70000,
"vbr": 700000,
"fr": 23
}
},
{
"format":{
"output_format":257
}
}
]
}
注:
1.presetParam必须是json格式数据
res = client.Preset(presetParam)
接口名: DelPreset
- 调用方式
res = client.DelPreset(App="live",UniqName="test",Preset=presetname)
接口名: GetPresetList
- 调用方式
res = client.GetPresetList(App="live",UniqName="test")
接口名: GetPresetDetail
- 调用方式
res = client.GetPresetDetail(App="live",UniqName="test",Preset=presetname)
接口名: GetStreamTranList
- 调用方式
res = client.GetStreamTranList(App="live",UniqName="test",StreamID="test",OutPull=-1)
接口名: StartStreamPull
- 调用方式
StartStreamPullParam = {
"UniqName":"test",
"App":"live",
"StreamID":"testName",
"SrcUrl":"test.uplive.ks-cdn.com"
}
注:
1.StartStreamPullParam必须是json格式数据
res = client.StartStreamPull(StartStreamPullParam)
接口名: StopStreamPull
- 调用方式
StopStreamPullParam = {
"UniqName":"test",
"App":"live",
"StreamID":"testName"
}注:
1.StopStreamPullParam必须是json格式数据
res = client.StopStreamPull(StopStreamPullParam)
接口名: StartLoop
- 调用方式
StartLoopParam = {
"UniqName": "test",
"App": "live",
"StreamID": "testName",
"Preset": "1080",
"PubDomain": "test.uplive.ksyun.com",
"DurationHour":168,
"SrcInfo": [
{
"Path": "http://wangshuai9.ks3-cn-beijing.ksyun.com/ksyun.flv",
"Index": 0
}
]
}注:
1.StartLoopParam必须是json格式数据
res = client.StartLoop(StartLoopParam)
接口名: StopLoop
- 调用方式
StopLoopParam = {
"UniqName": "test",
"App": "live",
"StreamID": "testName"
}注:
1.StopLoopParam必须是json格式数据
res = client.StopLoop(StopLoopParam)
接口名: UpdateLoop
- 调用方式
UpdateLoopParam = {
"UniqName": "test",
"App": "live",
"StreamID": "testName",
"DurationHour":100,
}注:
1.UpdateLoopParam必须是json格式数据
res = client.UpdateLoop(UpdateLoopParam)
接口名: GetLoopList
- 调用方式
res = client.GetLoopList(App=appname, UniqName=uniqname, StreamID=streamid)
接口名: GetQuotaUsed
- 调用方式
res = client.GetQuotaUsed(UniqName="test")
接口名:CreateDirectorTask
- 调用方式
param4 = {
"UniqName": uniqname,
"App": appname,
"Preset": presetname,
"SrcInfo": [
{
"Url": "rtmp://host/app/outernetStreamForSwitch",
"Idx": 0
},
{
"Streamid": "streamForSwitch",
"Idx": 1
}
],
"DstInfo": [
{
"Streamid":"stream0ForMonitor",
"Idx": 0
},
{
"Streamid": "stream1ForSwitch",
"Idx": 1
},
{
"Streamid": "stream2ForSwitch",
"Idx": 2
}
]
}
res = client.CreateDirectorTask(param4)
print json.dumps(res)
接口名:UpdateDirectorTask
- 调用方式
param4["TaskID"] = taskid
res = client.UpdateDirectorTask(param4)
print json.dumps(res)
接口名:QueryDirectorTask
- 调用方式
res = client.QueryDirectorTask(App=appname, UniqName=uniqname, TaskID=taskid)
print json.dumps(res)
接口名:DelDirectorTask
- 调用方式
res = client.DelDirectorTask(App=appname, UniqName=uniqname, TaskID=taskid)
print json.dumps(res)