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.
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
andPageSize
are used to obtain some data without passingScrollToken
orSessionId
. 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
andPageSize
pagination parameters and theScrollToken
andSessionId
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.
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
Sample request:
|
Exact match | Query information about a video whose
Sample request:
|
Fuzzy match | Query media asset information where
or
Sample request:
|
Multi-value query | Query information about a media asset whose
Sample request:
|
Range query | Use an open or closed interval to indicate a time range. Query information about a media asset whose
Sample request:
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
Sample request:
|
Sort field | Sort media asset information in reverse chronological order based on the creation time:
Sample request:
|