初始化客户端
使用前请先初始化客户端,请参见
获取播放地址
调用GetPlayInfo接口,完成获取播放地址功能。
接口参数和返回字段请参见from aliyunsdkvod.request.v20170321 import GetPlayInfoRequest
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('', '')
playInfo = get_play_info(clt, '')
print(json.dumps(playInfo, ensure_ascii=False, indent=4))
except Exception as e:
print(e)
print(traceback.format_exc())
获取视频播放凭证
调用GetVideoPlayAuth接口,完成获取视频播放凭证功能。
接口参数和返回字段请参见from aliyunsdkvod.request.v20170321 import GetVideoPlayAuthRequest
def get_video_playauth(clt, videoId):
request = GetVideoPlayAuthRequest.GetVideoPlayAuthRequest()
request.set_accept_format('JSON')
request.set_VideoId(videoId)
request.set_AuthInfoTimeout(3000)
response = json.loads(clt.do_action_with_exception(request))
return response
try:
clt = init_vod_client('', '')
playAuth = get_video_playauth(clt, '')
print(json.dumps(playAuth, ensure_ascii=False, indent=4))
except Exception as e:
print(e)
print(traceback.format_exc())