Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

vodtest2.py 1.3KB

2 år sedan
1234567891011121314151617181920212223242526272829
  1. import json
  2. import traceback
  3. from aliyunsdkcore.client import AcsClient
  4. from aliyunsdkvod.request.v20170321 import CreateUploadVideoRequest
  5. from aliyunsdkvod.request.v20170321 import GetPlayInfoRequest
  6. from voduploadsdk.AliyunVodUtils import *
  7. from voduploadsdk.AliyunVodUploader import AliyunVodUploader
  8. from voduploadsdk.UploadVideoRequest import UploadVideoRequest
  9. # 获取播放地址
  10. def init_vod_client(accessKeyId, accessKeySecret):
  11. regionId = 'cn-shanghai' # 点播服务接入地域
  12. connectTimeout = 3 # 连接超时,单位为秒
  13. return AcsClient(accessKeyId, accessKeySecret, regionId, auto_retry=True, max_retry_time=3, timeout=connectTimeout)
  14. def get_play_info(clt, videoId):
  15. request = GetPlayInfoRequest.GetPlayInfoRequest()
  16. request.set_accept_format('JSON')
  17. request.set_VideoId(videoId)
  18. request.set_AuthTimeout(3600*5)
  19. response = json.loads(clt.do_action_with_exception(request))
  20. return response
  21. try:
  22. clt = init_vod_client('LTAI5tSJ62TLMUb4SZuf285A', 'MWYynm30filZ7x0HqSHlU3pdLVNeI7')
  23. playInfo = get_play_info(clt, "f2bd66de44f742a5bb7d603c295dc47f")
  24. print(json.dumps(playInfo, ensure_ascii=False, indent=4))
  25. except Exception as e:
  26. print(str(e))
  27. print("403" in str(e))
  28. # print(traceback.format_exc())