Skip to content

Commit ada5825

Browse files
author
金山云SDK
authored
Merge pull request KscSDK#55 from KscSDK/master
同步master到truck
2 parents 42bf6ed + baacb75 commit ada5825

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+870
-182
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea*

examples/.kscore.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[Credentials]
2-
ks_access_key_id = AKTPr-ZiuofGTtqq2zsLI0eTKQ
3-
ks_secret_access_key = OApkXZjwEFtrTTAiJh1thYNnCgbXycP3Nk3B2akZO8zmLd8jIOX7IFrpoizCBiMrbw==
2+
ks_access_key_id = AKLTak2xkznHTVSs7a-8klJWug
3+
ks_secret_access_key = OEZTydYQ7suCyRwmv+s5L89g7gpNvB3PxJmPvxw3MXLIe6/N8Hsm8aXKPXD5+VvCKQ==

examples/cdn.py

Lines changed: 348 additions & 156 deletions
Large diffs are not rendered by default.

examples/eip.py

100755100644
File mode changed.

examples/ket.py

Lines changed: 144 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,67 @@
11
#!/usr/bin/python
22
# -*- coding: UTF-8 -*-
33
from kscore.ket import getKetClient
4+
import time
45
import json
56

67
if __name__ == "__main__":
78
client = getKetClient("ket", "cn-beijing-6",use_ssl=False)
89

910
uniqname = 'mytest'
10-
presetname = 'testpreset00'
11+
presetname = 'testpreset'
1112
appname = 'live'
1213
description = 'just a demo'
13-
presetType = 'avop'
14+
presettype = 4
1415
streamid = 'myteststreamid'
16+
taskid = 'd41d8cd98f00b204e9800998ecf8427e'
1517
outpull = 1
1618
srcurl = "rtmp://qa-ws.test-rtmplive.ks-cdn.com/live/20160819"
1719

20+
# 删除模板
21+
#res = client.DelPreset(App=appname, UniqName=uniqname, Preset=presetname)
22+
#print json.dumps(res)
23+
1824
# 创建模板
1925
param = {
2026
"UniqName": uniqname,
2127
"Preset": presetname,
28+
"PresetType": presettype,
2229
"Description": description,
2330
"App": appname,
2431
"Output": [
2532
{
26-
"format":
33+
"Idx": 0,
34+
"Overlay":[
35+
{
36+
"inputIdx": 0,
37+
}
38+
],
39+
"Amix":[
40+
{
41+
"inputIdx": 0,
42+
}
43+
]
44+
},
45+
{
46+
"Idx": 1,
47+
"Overlay":
48+
{
49+
"inputIdx": 0,
50+
},
51+
"Amix":
52+
{
53+
"inputIdx": 0,
54+
}
55+
},
56+
{
57+
"Idx": 2,
58+
"Video":
59+
{
60+
"codec": "copy",
61+
},
62+
"Audio":
2763
{
28-
"output_format": 257,
29-
"abr": 70000,
30-
"vbr": 700000,
31-
"fr": 23
64+
"codec": "copy",
3265
}
3366
}
3467
]
@@ -48,10 +81,6 @@
4881
res = client.GetPresetList(App=appname, UniqName=uniqname)
4982
print json.dumps(res)
5083

51-
# 删除模板
52-
res = client.DelPreset(App=appname, UniqName=uniqname, Preset=presetname)
53-
print json.dumps(res)
54-
5584
# 启动外网拉流
5685
param1 = {
5786
"UniqName": uniqname,
@@ -79,3 +108,107 @@
79108
# 获取用户已占用配额
80109
res = client.GetQuotaUsed(UniqName=uniqname)
81110
print json.dumps(res)
111+
112+
# 发起轮播任务
113+
param3 = {
114+
"UniqName": uniqname,
115+
"App": appname,
116+
"StreamID": streamid,
117+
"Preset": presetname,
118+
"PubDomain": "test.uplive.ksyun.com",
119+
"DurationHour":168,
120+
"SrcInfo": [
121+
{
122+
"Path": "http://wangshuai9.ks3-cn-beijing.ksyun.com/ksyun.flv",
123+
"Index": 0
124+
}
125+
]
126+
}
127+
res = client.StartLoop(param3)
128+
print json.dumps(res)
129+
130+
# 更新轮播时长
131+
param5 = {
132+
"UniqName": uniqname,
133+
"App": appname,
134+
"StreamID": streamid,
135+
"DurationHour":100,
136+
}
137+
res = client.UpdateLoop(param5)
138+
print json.dumps(res)
139+
140+
# 查询轮播列表
141+
res = client.GetLoopList(App=appname, UniqName=uniqname, StreamID=streamid)
142+
print json.dumps(res)
143+
144+
# 停止轮播任务
145+
param4 = {
146+
"UniqName": uniqname,
147+
"App": appname,
148+
"StreamID": streamid,
149+
}
150+
res = client.StopLoop(param4)
151+
print json.dumps(res)
152+
153+
#查询直播转码时长统计数据接口调用示例 : GetLiveTransDuration
154+
#参数
155+
# StartUnixTime:查询起始时间戳秒数
156+
# EndUnixTime:查询截止时间戳秒数
157+
# Granularity:统计时间粒度
158+
# ResultType:返回结果类型
159+
start = "2017-06-16 00:00:00"
160+
end = "2017-06-20 00:00:00"
161+
t0 = time.strptime(start, "%Y-%m-%d %H:%M:%S")
162+
t1 = time.strptime(end, "%Y-%m-%d %H:%M:%S")
163+
startunixtime = int(time.mktime(t0))
164+
endunixtime = int(time.mktime(t1))
165+
granularity = 5
166+
resulttype = 1
167+
res = client.GetLiveTransDuration(startunixtime, endunixtime, uniqname, granularity, resulttype)
168+
print json.dumps(res)
169+
170+
# 创建选流任务
171+
param4 = {
172+
"UniqName": uniqname,
173+
"App": appname,
174+
"Preset": presetname,
175+
"SrcInfo": [
176+
{
177+
"Url": "rtmp://host/app/outernetStreamForSwitch",
178+
"Idx": 0
179+
},
180+
{
181+
"Streamid": "streamForSwitch",
182+
"Idx": 1
183+
}
184+
],
185+
"DstInfo": [
186+
{
187+
"Streamid":"stream0ForMonitor",
188+
"Idx": 0
189+
},
190+
{
191+
"Streamid": "stream1ForSwitch",
192+
"Idx": 1
193+
},
194+
{
195+
"Streamid": "stream2ForSwitch",
196+
"Idx": 2
197+
}
198+
]
199+
}
200+
res = client.CreateDirectorTask(param4)
201+
print json.dumps(res)
202+
203+
#更新选流任务
204+
param4["TaskID"] = taskid
205+
res = client.UpdateDirectorTask(param4)
206+
print json.dumps(res)
207+
208+
#查询选流任务
209+
res = client.QueryDirectorTask(App=appname, UniqName=uniqname, TaskID=taskid)
210+
print json.dumps(res)
211+
212+
#删除选流任务
213+
res = client.DelDirectorTask(App=appname, UniqName=uniqname, TaskID=taskid)
214+
print json.dumps(res)

examples/kvs.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- encoding:utf-8 -*-
22
from kscore.kvs import getKvsClient
33
import json
4+
import time
45

56
#没有配置kscore.cfg调用方式
67
#ks_access_key_id='xxxxxxxxxxxxxxxxxxxx'
@@ -66,6 +67,23 @@
6667
res = client.DelPreset(Preset=presetname)
6768
print json.dumps(res)
6869

70+
#修改任务队列接口调用示例 : UpdatePipeline
71+
# 该接口需要输入json格式数据
72+
pipeinfo = {
73+
"PipelineName": "usual",
74+
"Description": "test pipeline",
75+
"State": "Active",
76+
"RegularStart": "01:00:00",
77+
"RegularDuration":7200
78+
}
79+
res = client.UpdatePipeline(pipeinfo)
80+
print json.dumps(res)
81+
82+
#查询任务队列接口调用示例 : QueryPipeline
83+
# PipelineName:队列名称
84+
res = client.QueryPipeline(PipelineName="usual")
85+
print json.dumps(res)
86+
6987

7088
#创建任务接口调用示例 : CreateTask
7189
#具体参数请参考官方文档
@@ -124,3 +142,28 @@
124142
# Limit:单次请求的记录数,默认为100,最大值为100
125143
res = client.GetTaskMetaInfo(StartDate=20170100,EndDate=20170112,Marker=0,Limit=50)
126144
print json.dumps(res)
145+
146+
#查询转码时长统计数据接口调用示例 : GetMediaTransDuration
147+
#查询转码API调用次数统计数据接口调用示例 : GetInterfaceNumber
148+
#查询转码截图统计数据接口调用示例 : GetScreenshotNumber
149+
#参数
150+
# StartUnixTime:查询起始时间戳秒数
151+
# EndUnixTime:查询截止时间戳秒数
152+
# Granularity:统计时间粒度
153+
# ResultType:返回结果类型
154+
start = "2017-06-16 00:00:00"
155+
end = "2017-06-20 00:00:00"
156+
t0 = time.strptime(start, "%Y-%m-%d %H:%M:%S")
157+
t1 = time.strptime(end, "%Y-%m-%d %H:%M:%S")
158+
StartUnixTime = int(time.mktime(t0))
159+
EndUnixTime = int(time.mktime(t1))
160+
Granularity = 5
161+
ResultType = 1
162+
res = client.GetMediaTransDuration(StartUnixTime, EndUnixTime, Granularity, ResultType)
163+
print json.dumps(res)
164+
165+
res = client.GetInterfaceNumber(StartUnixTime, EndUnixTime, Granularity, ResultType)
166+
print json.dumps(res)
167+
168+
res = client.GetScreenshotNumber(StartUnixTime, EndUnixTime, Granularity, ResultType)
169+
print json.dumps(res)

examples/network.py

100755100644
File mode changed.

examples/slb.py

100755100644
File mode changed.

examples/vpc.py

100755100644
File mode changed.

kscore/__init__.pyc

-3 Bytes
Binary file not shown.

kscore/auth.pyc

24.1 KB
Binary file not shown.

kscore/client.pyc

21.2 KB
Binary file not shown.

kscore/compat.pyc

8.8 KB
Binary file not shown.

kscore/config.pyc

5.03 KB
Binary file not shown.

kscore/configloader.pyc

7.1 KB
Binary file not shown.

kscore/credentials.pyc

33 KB
Binary file not shown.

0 commit comments

Comments
 (0)