Skip to content

Commit ebb7d1f

Browse files
author
金山云SDK
authored
Merge pull request KscSDK#8 from zhugelaing888/trunk
add offline sdk
2 parents 3a0628f + 029d1fb commit ebb7d1f

File tree

3 files changed

+218
-0
lines changed

3 files changed

+218
-0
lines changed

examples/offline.py

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# -*- encoding:utf-8 -*-
2+
from kscore.session import get_session
3+
import json
4+
5+
#初始化
6+
s = get_session()
7+
#注:参数不能改变
8+
client = s.create_client("offline", "cn-beijing-6", use_ssl=False)
9+
10+
#创建模板接口调用示例 : preset
11+
presetname = 'testpreset'
12+
description = 'just a demo'
13+
presetType = 'avop'
14+
15+
#具体的格式请参考官网说明
16+
param = {
17+
"preset": presetname,
18+
"description": description,
19+
"presettype": presetType,
20+
"param": {
21+
"f": "mp4",
22+
"AUDIO": {
23+
"acodec": "aac",
24+
"ar":"44100",
25+
"ab":"64k"
26+
},
27+
"VIDEO": {
28+
"vr": 25,
29+
"vb": "500k",
30+
"vcodec": "h264",
31+
"width": 640,
32+
"height": 360
33+
}
34+
}
35+
}
36+
37+
#该接口需要输入json格式数据,并且在参数前面加上"**"
38+
res = client.preset(**param)
39+
print json.dumps(res)
40+
41+
42+
#更新模板接口调用示例 : update_preset
43+
#该接口需要输入json格式数据,并且在参数前面加上"**"
44+
res = client.update_preset(**param)
45+
print json.dumps(res)
46+
47+
#获取模板列表接口调用示例 : get_preset_list
48+
res = client.get_preset_list()
49+
print json.dumps(res)
50+
51+
#获取模板信息接口调用示例 : get_preset_detail
52+
res = client.get_preset_detail(preset = presetname)
53+
print json.dumps(res)
54+
55+
#删除模板接口调用示例 : del_preset
56+
res = client.del_preset(preset = presetname)
57+
print json.dumps(res)
58+
59+
60+
#创建任务接口调用示例 : create_task
61+
#具体参数请参考官方文档
62+
task = {
63+
"dstDir": "",
64+
"dstObjectKey": "4.mp4",
65+
"dstBucket": "autotestoffline",
66+
"dstAcl": "public-read",
67+
"preset": presetname,
68+
"srcInfo": [
69+
{
70+
"path": "/autotestoffline/11.mp4",
71+
"type": "video",
72+
"index": 0
73+
}
74+
],
75+
"cbMethod": "POST",
76+
"cbUrl": "http://10.4.2.38:19090/"
77+
}
78+
79+
#该接口需要输入json格式数据,并且在参数前面加上"**"
80+
res = client.create_task(**task)
81+
print json.dumps(res)
82+
83+
#查看任务状态接口调用示例 : get_task_by_task_id
84+
taskid = "40d309d3b2bf373cd3f08e5b5e1bddf720160816"
85+
res = client.get_task_by_task_id(taskid = taskid)
86+
print json.dumps(res)
87+
88+
#获取任务列表接口调用示例 : get_task_list
89+
res = client.get_task_list()
90+
print json.dumps(res)
91+
92+
#删除任务接口调用示例 : del_task_by_task_id
93+
res = client.del_task_by_task_id(taskid = taskid)
94+
print json.dumps(res)
95+
96+
#任务置顶接口调用示例 : top_task_by_task_id
97+
res = client.top_task_by_task_id(taskid = taskid)
98+
print json.dumps(res)

kscore/data/endpoints.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,14 @@ partitions:
8888
protocols:
8989
- http
9090
- https
91+
offline:
92+
defaults:
93+
credentialScope:
94+
service: offline
95+
EndpointRegion: cn-beijing-6
96+
endpoints:
97+
cn-beijing-6:
98+
protocols:
99+
- http
91100

92101

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
---
2+
version: '2.0'
3+
metadata:
4+
apiVersion: '2016-09-19'
5+
endpointPrefix: offline
6+
jsonVersion: '1.1'
7+
serviceFullName: KSC OFFLINE Service
8+
signatureVersion: v4
9+
targetPrefix: offline
10+
protocol: json2
11+
12+
operations:
13+
Preset:
14+
name: Preset
15+
http:
16+
method: POST
17+
18+
UpdatePreset:
19+
name: UpdatePreset
20+
http:
21+
method: POST
22+
23+
DelPreset:
24+
name: DelPreset
25+
http:
26+
method: GET
27+
requestUri: /
28+
input:
29+
shape: PresetInstance
30+
31+
GetPresetList:
32+
name: GetPresetList
33+
http:
34+
method: GET
35+
requestUri: /
36+
input:
37+
shape: WithDetailInstance
38+
39+
GetPresetDetail:
40+
name: GetPresetDetail
41+
http:
42+
method: GET
43+
requestUri: /
44+
input:
45+
shape: PresetInstance
46+
47+
CreateTask:
48+
name: CreateTask
49+
http:
50+
method: POST
51+
52+
DelTaskByTaskID:
53+
name: DelTaskByTaskID
54+
http:
55+
method: GET
56+
requestUri: /
57+
input:
58+
shape: TaskIDInstance
59+
60+
TopTaskByTaskID:
61+
name: TopTaskByTaskID
62+
http:
63+
method: GET
64+
requestUri: /
65+
input:
66+
shape: TaskIDInstance
67+
68+
GetTaskList:
69+
name: GetTaskList
70+
http:
71+
method: GET
72+
requestUri: /
73+
74+
GetTaskByTaskID:
75+
name: GetTaskByTaskID
76+
http:
77+
method: GET
78+
requestUri: /
79+
input:
80+
shape: TaskIDInstance
81+
82+
shapes:
83+
Preset:
84+
type: string
85+
WithDetail:
86+
type: integer
87+
TaskID:
88+
type: string
89+
min: 35
90+
max: 45
91+
PresetInstance:
92+
type: structure
93+
required:
94+
- preset
95+
members:
96+
preset:
97+
shape: Preset
98+
WithDetailInstance:
99+
type: structure
100+
members:
101+
withDetail:
102+
shape: WithDetail
103+
TaskIDInstance:
104+
type: structure
105+
required:
106+
- taskid
107+
members:
108+
taskid:
109+
shape: TaskID
110+
111+

0 commit comments

Comments
 (0)