|
- import json
- import traceback
- from aliyunsdkcore.client import AcsClient
- from aliyunsdkvod.request.v20170321 import CreateUploadVideoRequest
- from aliyunsdkvod.request.v20170321 import GetPlayInfoRequest
- from voduploadsdk.AliyunVodUtils import *
- from voduploadsdk.AliyunVodUploader import AliyunVodUploader
- from voduploadsdk.UploadVideoRequest import UploadVideoRequest
- # 获取播放地址
- def init_vod_client(accessKeyId, accessKeySecret):
- regionId = 'cn-shanghai' # 点播服务接入地域
- connectTimeout = 3 # 连接超时,单位为秒
- return AcsClient(accessKeyId, accessKeySecret, regionId, auto_retry=True, max_retry_time=3, timeout=connectTimeout)
- def get_play_info(clt, videoId):
- request = GetPlayInfoRequest.GetPlayInfoRequest()
- request.set_accept_format('JSON')
- request.set_VideoId(videoId)
- request.set_AuthTimeout(3600*5)
- response = json.loads(clt.do_action_with_exception(request))
- return response
- try:
- clt = init_vod_client('LTAI5tSJ62TLMUb4SZuf285A', 'MWYynm30filZ7x0HqSHlU3pdLVNeI7')
- playInfo = get_play_info(clt, "f2bd66de44f742a5bb7d603c295dc47f")
- print(json.dumps(playInfo, ensure_ascii=False, indent=4))
-
- except Exception as e:
- print(str(e))
- print("403" in str(e))
- # print(traceback.format_exc())
|