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.
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.
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
SessionId pagination identifiers.
Pagination parameters such as
PageSizeare used to obtain some data without passing
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
PageSizepagination parameters and the
SessionIdpagination 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.
By default, the SearchMedia operation returns only basic media asset information. To obtain more media asset information, you must set the
Query information about a video whose
Query media asset information where
Query information about a media asset whose
Use an open or closed interval to indicate a time range. Query information about a media asset whose
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
Sort media asset information in reverse chronological order based on the creation time: