All Products
Search
Document Center

ApsaraVideo VOD:Query media asset information

Last Updated:Sep 14, 2022

You can query, filter, and sort information about media assets such as video, audio, and image files in the media library that match the query conditions. This topic describes how to query media asset information by using the ApsaraVideo VOD console, API operations, or SDKs. This topic also describes the limits and provides examples on how to query media asset information by calling API operations.

Methods

You can use the following two methods to query media asset information:

  • By using the ApsaraVideo VOD console

    On the Video and Audio page in the ApsaraVideo VOD console, you can query information about a media asset by its name or ID. For more information, see Manage media assets.ApsaraVideo VOD console

  • By using the API operations or SDKs

    Call the SearchMedia operation and use the search protocol to query media asset information. You can call the SearchMedia operation to query media asset information and specify the fields to return. Multiple query modes are supported, such as exact match, fuzzy match, multi-value query, and range query. You can filter media asset information based on VideoId, CateId, StorageLocation, Title, or Tags. For more information about the search syntax and rules, see Protocol for media asset search.

Limits

Paging limits

To avoid performance problems caused by deep paging, the SearchMedia operation returns only part of the data that meets the query conditions. To obtain more data or traverse all data, you must use the ScrollToken and SessionId pagination identifiers.

  • Pagination parameters such as PageNo and PageSize are used to obtain some data without passing ScrollToken or SessionId. You can obtain the first 5,000 data records for one query.

  • To obtain more data or traverse all data, you must use the PageNo and PageSize pagination parameters and the ScrollToken and SessionId pagination identifiers. Make sure that the number of data records on pages between the current page number and the required page number does not exceed 1,200. When you go to the page specified by the required page number, you can obtain the next 1,200 data records. Repeat the preceding operations to obtain all data. You can obtain data in multiple segments based on the pagination identifiers. However, you can obtain a maximum of 1,200 data records in each segment.

API call examples

The sample code in the following section describes the query statements used for querying video information.

Notice
  • Before you send a request, you must perform URL encoding on the request parameters.

  • The equal signs (=), double quotation marks ("), single quotation marks ('), and parentheses used in the statement must be single-byte characters.

Item

Description

Return field

By default, the SearchMedia operation returns only basic media asset information. To obtain more media asset information, you must set the Fields field. Obtain the Title and CoverURL parameters:

Fields=Title,CoverURL

Sample request:

http://vod.cn-shanghai.aliyuncs.com?Action=SearchMedia
&Fields=Title,CoverURL

Exact match

Query information about a video whose VideoId is 28ba2b26d540446c94cdd2c4c48090e5:

VideoId='28ba2b26d540446c94cdd2c4c48090e5'

Sample request:

http://vod.cn-shanghai.aliyuncs.com?Action=SearchMedia
&Match=VideoId='28ba2b26d540446c94cdd2c4c48090e5'

Fuzzy match

Query media asset information where Title contains Music:

Title='Music'

or

Title in ('Music')

Sample request:

http://vod.cn-shanghai.aliyuncs.com?Action=SearchMedia
&Match=Title='Music'

Multi-value query

Query information about a media asset whose Status is Normal or Checking:

Status in ('Normal','Checking')

Sample request:

http://vod.cn-shanghai.aliyuncs.com?Action=SearchMedia
&Match=Status in ('Normal','Checking')

Range query

Use an open or closed interval to indicate a time range. Query information about a media asset whose CreationTime is between 2018-01-01T00:00:00Z and 2018-02-01T00:00:00Z:

CreationTime=('2018-01-01T00:00:00Z','2018-02-01T00:00:00Z')

Sample request:

http://vod.cn-shanghai.aliyuncs.com?Action=SearchMedia
&Match=CreationTime=('2018-01-01T00:00:00Z','2018-02-01T00:00:00Z')

Use a left-open or right-open interval to specify only the end time or the start time of a time range. Query information about a media asset whose CreationTime is later than 2018-01-01T00:00:00Z:

CreationTime=('2018-01-01T00:00:00Z',)

Sample request:

http://vod.cn-shanghai.aliyuncs.com?Action=SearchMedia
&Match=CreationTime=('2018-01-01T00:00:00Z',)

Sort field

Sort media asset information in reverse chronological order based on the creation time:

CreationTime:Desc

Sample request:

http://vod.cn-shanghai.aliyuncs.com?Action=SearchMedia
&SortBy=CreationTime:Desc