前置条件

初始化

点播服务的接入区域参考接入区域标识,例如:接入区域在上海,请使用cn-shanghai

  • 使用账号AccessKey初始化
    # -*- coding: UTF-8 -*-
    import json
    import traceback
    from aliyunsdkcore.client import AcsClient
    
    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)
    			
  • 使用STS初始化
    # -*- coding: UTF-8 -*-
    import json
    import traceback
    from aliyunsdkcore.client import AcsClient
    from aliyunsdkcore.auth.credentials import StsTokenCredential
    
    def init_vod_client(accessKeyId, accessKeySecret, securityToken):
        regionId = 'cn-shanghai'   # 点播服务接入区域
        connectTimeout = 3         # 连接超时,单位为秒
        credential = StsTokenCredential(accessKeyId, accessKeySecret, securityToken)
        return AcsClient(region_id=regionId, auto_retry=True, max_retry_time=3, timeout=connectTimeout, credential=credential)