kls.py 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #!/usr/bin/python
  2. # -*- coding: UTF-8 -*-
  3. from kscore.kls import getKlsClient
  4. import json
  5. if __name__ == "__main__":
  6. #ks_access_key_id='xxxxxxxxxxxxxxxxxxxxxxxxxx'
  7. #ks_secret_access_key='xxxxxxxxxxxxxxxxxxxxxxxxxx'
  8. client = getKlsClient("kls", "cn-beijing-6",use_ssl=False)
  9. #client = getKlsClient("kls", "cn-beijing-6",use_ssl=False,ks_access_key_id=ks_access_key_id,ks_secret_access_key=ks_secret_access_key)
  10. param = {
  11. "UniqueName":"test",
  12. "App":"live",
  13. "Pubdomain":"test.uplive.ks-cdn.com",
  14. "Stream":"yangfan21",
  15. "Mp4VodEnable":1,
  16. "Ks3FileNameM3u8":"a23{Pubdomain}23sf{AppName}",
  17. "Ks3FullPathMP4":"record-1/{UniqueName}/{AppName}/{Pubdomain}/{StreamName}/mp4/{StreamName}-{UnixTimestamp}-activity",
  18. "StartUnixtime":1489485300,
  19. "EndUnixtime":1489485480
  20. }
  21. # 查询推流实时信息接口: ListRealtimePubStreamsInfo
  22. res = client.ListRealtimePubStreamsInfo(UniqueName="test",App="live",Pubdomain="yangfan21.cn")
  23. print json.dumps(res)
  24. #定时录制接口需要输入json格式数据
  25. res = client.CreateRecordTask(param)
  26. print json.dumps(res)
  27. #定时录制取消接口需要输入json格式数据
  28. res = client.CancelRecordTask(param)
  29. print json.dumps(res)
  30. #查询录像任务状态接口(GetRecordTask)
  31. res = client.GetRecordTask(RecID = 2017)
  32. print json.dumps(res)
  33. #查询历史录制任务接口 ListHistoryRecordTasks
  34. res = client.ListHistoryRecordTasks(UniqueName="test",App="live",Pubdomain="yangfan21.cn",Stream="yangfan21",RecType=1,Limit=10,Marker=10,OrderTime=1,StartUnixTime=1489485300,EndUnixTime=1489485480)
  35. print json.dumps(res)
  36. #短视频开始录制接口 : StartStreamRecord
  37. res = client.StartStreamRecord(param)
  38. print json.dumps(res)
  39. #短视频开始录制接口 : StopStreamRecord
  40. res = client.StopStreamRecord(param)
  41. print json.dumps(res)
  42. #查询在线录制任务接口 : ListRecordingTasks
  43. res = client.ListRecordingTasks(UniqueName="test",App="live",Pubdomain="yangfan21.cn",Stream="yangfan21",RecType=1,Limit=10,Marker=10,OrderTime=1,RecStatusType=1)
  44. print json.dumps(res)
  45. #查询主播流时长接口 : ListStreamDurations
  46. res = client.ListStreamDurations(UniqueName="test",App="live",Pubdomain="yangfan21.cn",Stream="yangfan21",StartUnixTime=1489485300,EndUnixTime=1489485480)
  47. print json.dumps(res)
  48. #查询流历史信息接口 : ListHistoryPubStreamsInfo
  49. res = client.ListHistoryPubStreamsInfo(UniqueName="test",App="live",Pubdomain="yangfan21.cn",Stream="yangfan21",Limit=10,Marker=10,OrderTime=1,StartUnixTime=1489485300,EndUnixTime=1489485480)
  50. print json.dumps(res)
  51. #查询流历史错误信息接口 : ListHistoryPubStreamsErrInfo
  52. res = client.ListHistoryPubStreamsErrInfo(UniqueName="test",App="live",Pubdomain="yangfan21.cn",Stream="yangfan21",Limit=10,Marker=10,OrderTime=1,StartUnixTime=1489485300,endUnixTime=1489485480)
  53. print json.dumps(res)
  54. #禁止单路直播流推送 : ForbidStream
  55. res = client.ForbidStream(param)
  56. print json.dumps(res)
  57. #恢复单路直播流推送 : ResumeStream
  58. res = client.ResumeStream(param)
  59. print json.dumps(res)
  60. #查询黑名单列表 : GetBlacklist
  61. res = client.GetBlacklist(UniqueName="test",App="live",Pubdomain="yangfan21.cn")
  62. print json.dumps(res)
  63. #踢拉流接口 : KillStreamCache
  64. res = client.KillStreamCache(param)
  65. print json.dumps(res)
  66. #查询主播汇总实时信息接口 : ListRealtimeStreamsInfo
  67. res = client.ListRealtimeStreamsInfo(param)
  68. print json.dumps(res)