全部产品

内容库管理

本篇文档提供了Python SDK内容库管理模块相关功能的API调用示例。主要包含注册内容库资源、获取媒资内容信息、更新媒资内容信息、删除媒资内容、列出符合条件的媒资基础信息。

初始化客户端

使用前请先初始化客户端,请参见初始化

注册内容库资源

调用RegisterMediaInfo接口,完成注册内容库媒资信息功能。

接口参数和返回字段请参见注册内容库资源。调用示例如下:

from alibabacloud_ice20201109.models import RegisterMediaInfoRequest

def register_media_info(client):
    request = RegisterMediaInfoRequest()
    request.input_url = 'http://example-bucket.oss-cn-shanghai.aliyuncs.com/example.mp4'
    request.media_type = 'video'
    request.business_type = 'video'
    request.title = 'default_title'

    response = client.register_media_info(request)
    print(response)
    print('request id:', response.body.request_id)
    print('media info:', response.body.media_id)
    
if __name__ == '__main__':
    client = init_ice_client_ak('<your-access-key>', '<your-access-secret>')
    register_media_info(client)
    

获取媒资内容信息

调用GetMediaInfo接口,完成获取媒资内容信息功能。

接口参数和返回字段请参见获取媒资内容信息。调用示例如下:

from alibabacloud_ice20201109.models import GetMediaInfoRequest

def get_media_info(client):
    request = GetMediaInfoRequest()
    # get media info by mediaId
    request.media_id = '****20b48fb04483915d4f2cd8ac****'
    # get media info by inputUrl
    # request.input_url = 'http://example-bucket.oss-cn-shanghai.aliyuncs.com/example.mp4'

    response = client.get_media_info(request)
    print(response)
    print('request id:', response.body.request_id)
    print('media info:', response.body.media_info)

if __name__ == '__main__':
    client = init_ice_client_ak('<your-access-key>', '<your-access-secret>')
    get_media_info(client)
    

更新媒资内容信息

调用UpdateMediaInfo接口,完成更新媒资内容信息功能。

接口参数和返回字段请参见更新媒资内容信息。调用示例如下:

from alibabacloud_ice20201109.models import UpdateMediaInfoRequest

def update_media_info(client):
    request = UpdateMediaInfoRequest()
    # update media info by mediaId
    request.media_id = '****20b48fb04483915d4f2cd8ac****'
    # update media info by inputUrl
    # request.input_url = 'http://example-bucket.oss-cn-shanghai.aliyuncs.com/example.mp4'

    request.business_type = 'opening'
    request.title = 'default_title'
    request.media_tags = 'updateTag1,updateTags2'
    request.append_tags = True

    response = client.update_media_info(request)
    print(response)
    print('request id:', response.body.request_id)
    print('media info:', response.body.media_id)

if __name__ == '__main__':
    client = init_ice_client_ak('<your-access-key>', '<your-access-secret>')
    update_media_info(client)

删除媒资内容信息

调用DeleteMediaInfos接口,完成批量删除媒资内容信息功能。

接口参数和返回字段请参见删除媒资内容。调用示例如下:

from alibabacloud_ice20201109.models import DeleteMediaInfosRequest

def delete_media_infos(client):
    request = DeleteMediaInfosRequest()
    # delete media info by mediaId
    request.media_ids = '****20b48fb04483915d4f2cd8ac****,****81539d420bb04d8ac4f48f2c****'
    # delete media info by inputUrl
    # request.input_urls = 'http://example-bucket.oss-cn-shanghai.aliyuncs.com/example.mp4,http://example-bucket.oss-cn-shanghai.aliyuncs.com/example2.mp4'

    response = client.delete_media_infos(request)
    print(response)
    print('request id:', response.body.request_id)
    print('ignored list:', response.body.ignored_list)
    
if __name__ == '__main__':
    client = init_ice_client_ak('<your-access-key>', '<your-access-secret>')
    delete_media_infos(client)
    

列出符合条件的媒资基础信息

调用ListMediaBasicInfos接口,完成列出符合条件的媒资基础信息功能。

接口参数和返回字段请参见列出符合条件的媒资基础信息。调用示例如下:

注意

时间参数要使用UTC时间,北京时间与UTC的时差为+8,也就是UTC+8,例如2018-01-01T12:00:00Z表示北京时间2018年1月1日20点0分0秒。

from alibabacloud_ice20201109.models import ListMediaBasicInfosRequest

def list_media_basic_infos(client):
    request = ListMediaBasicInfosRequest()
    # set start time (exclusive)
    request.start_time = '2020-12-20T12:00:00Z'
    # set end time (inclusive)
    request.end_time = '2020-12-20T13:00:00Z'
    # set max return entries
    request.max_results = 5

    response = client.list_media_basic_infos(request)
    print(response)
    print('request id:', response.body.request_id)
    print('media info list:', response.body.media_infos)
    print('next token', response.body.next_token)
    print('max results', response.body.max_results)
    print('total count', response.total_count)

if __name__ == '__main__':
    client = init_ice_client_ak('<your-access-key>', '<your-access-secret>')
    list_media_basic_infos(client)