Media asset search

更新时间:
复制 MD 格式

You can use a server-side SDK to call the SearchMedia operation and search for media assets in Intelligent Media Services. This topic provides sample code in Java.

Usage notes

You can filter media assets by title, media asset ID, classification, and status. You can also specify the sort field and sort order for the results.

Sample code

Use Alibaba Cloud OpenAPI Explorer to debug this API online.

import json
import os
import sys
from typing import List

from alibabacloud_ice20201109.client import Client as ICE20201109Client
# Import Alibaba Cloud IMS SDK.
from alibabacloud_ice20201109 import models as ice20201109_models
# Import a client for credentials and SDKs of cloud services and create an alias for the client.
from alibabacloud_credentials.client import Client as CredClient
# Import the core package of Alibaba Cloud SDKs.
from alibabacloud_tea_openapi.models import Config


#######Required dependencies#############
#pip install alibabacloud_credentials
#pip install alibabacloud_ice20201109==1.3.11
class Sample:

    # Initialize the client.
    @staticmethod
    def create_client(region: str) -> ICE20201109Client:
        # Use the default credential to initialize the credentials client.
        cred = CredClient()
        config = Config(credential = cred)
        # Specify the endpoint of the cloud service.
        config.endpoint = 'ice.' + region + '.aliyuncs.com'
        # Use the credentials client to initialize the ECS SDK client.
        return ICE20201109Client(config)

    # @staticmethod
    # def create_client(
    #     access_key_id: str,
    #     access_key_secret: str,
    #     region: str,

    # ) -> ICE20201109Client:
    #     To hard-code your AccessKey ID and AccessKey secret, use the following code. However, we recommend that you do not save the AccessKey ID and the AccessKey secret in your project code. Otherwise, the AccessKey pair may be leaked and the security of resources within your account may be compromised.
    #     config = open_api_models.Config(
    #         # Required. Specify your AccessKey ID.
    #         access_key_id = access_key_id,
    #         # Required. Specify your AccessKey secret.
    #         access_key_secret = access_key_secret
    #     )
    #     # Specify the endpoint that you want to access.
    #     config.endpoint = 'ice.' + region + '.aliyuncs.com'
    #     return ICE20201109Client(config)

    # Read command line parameters.
    @staticmethod
    def main() -> None:
        region = 'cn-shanghai'
        client = Sample.create_client(region)
        request = ice20201109_models.SearchMediaRequest(
            match = "fullText = 'China'"
        )
        # Print the return value based on your business requirements.
        response = client.search_media(request)
        print('[LOG]', json.dumps(response.to_map()))


if __name__ == '__main__':
    Sample.main()

Related API operation

SearchMedia - Searches for media information