All Products
Search
Document Center

SearchMedia

Last Updated: Mar 06, 2019

Description

You can call this operation to search for media asset information, such as video, audio, or image information. This operation needs to be used together with the media asset search protocol.

Restrictions on the number of queried data records:

  • Method 1: To list all the first 5,000 data records that meet the specified filter criteria, you need to set the PageNo and PageSize parameters to list data by page. If the number of data records that meet the specified filter criteria exceeds 5,000, you need to use the method 2 to list all data.
  • Method 2: To list all the data records that meet the specified filter criteria, you need to set the PageNo, PageSize, and ScrollToken parameters to list data by page. The total number of data records from the current page to the target page cannot exceed 1,200. For example, the PageSize parameter is set to 20, which indicates that 20 data records are displayed on each page:
    • If the current page number is 1 (PageNo=1), you can page down to list data from page 1 to page 60 (PageNo=60) at most.
    • If the current page number is 2 (PageNo=2), you can page down to list data from page 2 to page 61 (PageNo=61) at most.
    • If the current page number is 61 (PageNo=61), you can page up to list data from page 61 to page 2 (PageNo=2) at most or page down to list data from page 61 to page 120 (PageNo=120) at most.

Request parameters

Name TypeRequiredDescription
ActionStringYesThe operation that you want to perform. Set the value to SearchMedia.
SearchType StringNoThe type of media asset information to be searched for. Valid values:
  • video (default value)
  • audio
  • image
FieldsStringNoThe media asset fields returned in the queried results.
Only the basic media asset fields are returned by default.
Match StringNoThe filter criteria. For more information about the syntax, see Syntax in Media asset search protocol.
ScrollToken StringNoThe page flip identifier. The value is a string of 32 characters. This parameter is required if all data is listed. This parameter is not contained in the first search request. Each time data records that meet the specified filter criteria are found, the value of this parameter is returned to record the current position of queried data.
SortBy StringNoThe sorting rule of results, including the sorting field and order. Separate multiple sorting fields with a comma (,). The results are sorted based on the creation time by default.
Valid values:
  • CreationTime:Desc
  • CreationTime:Asc
  • To obtain the first 5,000 data records that meet the specified filter criteria, you can specify a maximum of three sorting fields.
  • To list all the data records that meet the specified filter criteria, you can specify only one sorting field.
PageNo LongNoThe page number.
Default value: 1.
PageSize LongNoThe number of data records per page.
Default value: 10. Maximum value: 100.

Response parameters

NameTypeDescription
RequestIdString The GUID generated by Alibaba Cloud for the request.
ScrollTokenString The page flip identifier.
MediaListMedia[] The list of media asset information.
TotalLong The total number of data records that meet the specified filter criteria.

Examples

Sample requests

  1. http://vod.cn-shanghai.aliyuncs.com/?Action=SearchMedia&SearchType=video&Fields=VideoId,Title,Status,CoverURL,CreationTime,ModificationTime&Match=Title='Test' and Status in ('Normal')&PageNo=1&PageSize=10&ScrollToken=3de9654f6169e31d7aa2987244d0d6c7&SortBy=CreationTime:Desc&Version=2017-03-21&Format=JSON&<Common request parameters>

Note: For more information about common request parameters, see Common parameters.

Sample responses

JSON format

  1. {
  2. MediaList: [{
  3. CreationTime: "2018-07-20T04:29:04Z",
  4. MediaType: "video",
  5. MediaId: "afab53f582cf422f87689e1cf0425815",
  6. Video: {
  7. CoverURL: "http://sample.aliyun.com/cover01.jpg",
  8. CreationTime: "2018-07-20T04:29:04Z",
  9. Status: "Normal",
  10. ModificationTime: "2018-07-20T06:14:29Z",
  11. VideoId: "afab53f582cf422f87689e1cf0425815",
  12. Title: "Test title 01"
  13. }
  14. },
  15. {
  16. CreationTime: "2018-07-19T03:45:25Z",
  17. MediaType: "video",
  18. MediaId: "a82a2cd7d4e147bb96faa0ed6c1ee372",
  19. Video:{
  20. CoverURL: "http://sample.aliyun.com/cover02.jpg",
  21. CreationTime: "2018-07-19T03:45:25Z",
  22. Status: "Normal",
  23. ModificationTime: "2018-07-20T06:45:53Z",
  24. VideoId: "a82a2cd7d4e147bb96faa0ed6c1ee372",
  25. Title: "Test title 02"
  26. }
  27. },
  28. {
  29. CreationTime: "2018-07-05T02:43:55Z",
  30. MediaType: "video",
  31. MediaId: "62da1c9832e440b79fdc4dce0eac3d2a",
  32. Video: {
  33. CoverURL: "http://sample.aliyun.com/cover03.jpg",
  34. CreationTime: "2018-07-05T02:43:55Z",
  35. Status: "Normal",
  36. ModificationTime: "2018-07-05T05:41:29Z",
  37. VideoId: "62da1c9832e440b79fdc4dce0eac3d2a",
  38. Title: "Test title 03"
  39. }
  40. }...],
  41. RequestId: "3E0CEF83-FB09-4E47-8134-BA1451814B03",
  42. ScrollToken: "24e0fba7188fa01e880e707e146esa54",
  43. Total: 10
  44. }

Error codes

The following table lists the error codes that this operation can return. For more information, see Error codes.

Error codeError messageHTTP status codeDescription
SortByExceededMaxThe SortBy parameter only supports one sort field when traversing all data.400The error message returned when more than one sorting field is specified for listing all data.
ErrorMatchSyntaxThe parameter Match.%s has an error syntax, please check it.400The error message returned when the syntax of the Match parameter is invalid. Check the syntax and try again.
InvalidScrollToken.ExpiredThe ScrollToken is expired, please refresh it.400The error message returned when the value of the ScrollToken parameter expires. Data is obtained again from page 1.