最近更新时间:2024-08-15 11:05:42
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=xxxxxxxxxxxxxxxxxxxx
from kscore.kvs import getKvsClient
第一种:
client = getKvsClient("kvs", "cn-beijing-6",use_ssl=False)
参数说明:
service_name: 服务名,填写"kvs"
region_name: 区域名,填写"cn-beijing-6"
use_ssl: 是否https访问,填写False
第二种:
没有配置kscore.cfg调用方式
ks_access_key_id='xxxxxxxxxxxxxxxxxxxx'
ks_secret_access_key='xxxxxxxxxxxxxxxxxxxx'
参数:服务service_name,大区region_name
client = getKvsClient("kvs", "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版本
注: 接口的传递的参数及返回值请参考《视频云离线转码接入文档》API接口说明
接口名
Preset
调用方式
param = {
"Preset": "xxxx",
"Description": "xxxx",
"PresetType": "xxxx",
"Param":{
"f": "xxx",
"AUDIO": {
"ab": xxx,
"ar": xxx,
"acodec": "xxxx",
"an": xxx
},
"VIDEO": {
"vr": xxx,
"vb": "xxxx",
"vcodec": "xxxx",
"width": xxx,
"height": xxx,
"as": xxx,
"rotate": "xxxx",
"vn": xxx
}
}
}
注:
1.param必须是json格式数据
res = client.Preset(param)
接口名
UpdatePreset
调用方式
param = {
"Preset": "xxxx",
"Description": "xxxx",
"PresetType": "xxxx",
"Param":{
"f": "xxx",
"AUDIO": {
"ab": xxx,
"ar": xxx,
"acodec": "xxxx",
"an": xxx
},
"VIDEO": {
"vr": xxx,
"vb": "xxxx",
"vcodec": "xxxx",
"width": xxx,
"height": xxx,
"as": xxx,
"rotate": "xxxx",
"vn": xxx
}
}
}
注:
1.param必须是json格式数据
res = client.UpdatePreset(param)
接口名
GetPresetList
调用方式
res = client.GetPresetList(WithDetail=0,PresetType="xxx",Presets="xxx")
接口名
GetPresetDetail
调用方式
res = client.GetPresetDetail(Preset="xxx")
接口名
DelPreset
调用方式
res = client.DelPreset(Preset="xxx")
接口名
CreateTask
调用方式
task = {
"DstDir": "",
"DstObjectKey": "xxx",
"DstBucket": "xxx",
"DstAcl": "public-read",
"Preset": "xxx",
"SrcInfo": [
{
"path": "xxx",
"type": "video",
"index": 0
}
],
"CbMethod": "xxx",
"CbUrl": "xxx"
}
注:
1.task必须是json格式数据
res = client.CreateTask(task)
接口名
TopTaskByTaskID
调用方式
res = client.TopTaskByTaskID(TaskID = taskid)
接口名
DelTaskByTaskID
调用方式
res = client.DelTaskByTaskID(TaskID = taskid)
接口名
GetTaskList
调用方式
res = client.GetTaskList(StartDate=20170100,EndDate=20170112,Marker=0,Limit=50)
接口名
GetTaskByTaskID
调用方式
res = client.GetTaskByTaskID(TaskID = taskid)
接口名
GetTaskMetaInfo
调用方式
res = client.GetTaskMetaInfo(StartDate=20170100,EndDate=20170112,Marker=0,Limit=50)
接口名
QueryPipeline
调用方式
from kscore.session import get_session
import json
if __name__=="__main__":
# 密钥
ak = ""
sk = ""
s = get_session()
s.set_credentials(ak, sk)
client = s.create_client("kvs", "cn-beijing-6", use_ssl=False)
param = {
"preset": "wave",
"start_date": "20211006",
}
# 通过userid查询任务队列调用示例
client.query_task_stats(**param)
纯净模式