Search Videos
Updated: 2023-07-17 09:59:52
API Description
1、搜索视频详细内容
2、接口支持https协议
API URL
http://api.polyv.net/v2/video/search-videos
Request Method
GET
API Constraints
- The API supports both HTTP and HTTPS. HTTPS is recommended for security. API calls have frequency limits. See details
Request Parameters
| Parameter | Required | Type | Description |
|---|---|---|---|
| userid | true | String | POLYV VOD account ID. Refer to Get Secret Key. Path: Official Website -> Login -> VOD (API Interface) |
| ptime | true | Long | Current time in milliseconds, valid for 3 minutes |
| sign | true | String | Signature, a 40-character uppercase SHA1 value. The secretkey used to generate the signature is critical for data security. It must not be used directly on the client side. All APIs must be called through your own server to relay requests to the POLYV server for response data. See Signature Generation Rules |
| filters | false | String | Video information to return, separated by commas. Default returns only basic info. basicInfo: Basic information metaData: Metadata transcodeInfo: Transcoding information snapshotInfo: Snapshot information |
| cateId | false | Long | Video category ID. Obtained from Get Categories and Subcategories |
| title | false | String | Fuzzy search by title/video vid |
| tag | false | String | Fuzzy search by video tag |
| uploader | false | String | Uploader, e.g., main account |
| status | false | String | Video status. Default searches all statuses. Multiple statuses separated by commas. To query published videos, pass either 61 or 60, e.g., "61,50". Refer to Status Field Description |
| containSubCate | false | Boolean | Whether to include subcategories true: Include false: Exclude, default is true |
| startTime | false | Long | Query by creation time range, start timestamp, 13-digit timestamp |
| endTime | false | Long | End timestamp, 13-digit timestamp |
| startModifyTime | false | Long | Query by modification time range, start timestamp, 13-digit timestamp |
| endModifyTime | false | Long | End timestamp for modification time, 13-digit timestamp |
| encrypted | false | Boolean | Whether encrypted |
| playAuthEnable | false | Boolean | Whether playback authorization is enabled |
| sort | false | String | Result sorting. Can sort by creation time or play count ascending/descending. creationTimeAsc: Creation time ascending creationTimeDesc: Creation time descending playTimesAsc: Play count ascending playTimesDesc: Play count descending |
| page | false | Integer | Page number, default is 1 |
| pageSize | false | Integer | Page size, default is 10, maximum is 1000 |
Status Field Description
| Status Code | Description |
|---|---|
| 60/61 | Published |
| 10 | Waiting for encoding |
| 20 | Encoding |
| 50 | Pending review |
| 51 | Review failed |
| -1 | Deleted |
Example
http://api.polyv.net/v2/video/search-videos?cateId=1615795867474&uploader=%E4%B8%BB%E8%B4%A6%E5%8F%B7&sign=1BE730A20058481E794D3B5BE27ED9FBF7B491C0&containSubCate=true&pageSize=10&filters=basicInfo%2CmetaData&page=1&sort=creationTimeDesc&userid=1b448be323&ptime=1620289391124&status=60
Response Parameters
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Response status code. 200 for success, non-200 for failure. See Global Error Description |
| status | String | Response status text |
| message | String | Response description. When code is 400 or 500, provides error reason |
| data | Object | Search results on success See data Field Description, empty on failure |
data Field Description
| Field | Type | Description |
|---|---|---|
| pageNumber | Integer | Current page number |
| totalPages | Integer | Total pages |
| pageSize | Integer | Items per page |
| contents | Array | List of search results See contents Field Description |
| totalItems | Integer | Total items |
contents Field Description
| Field | Type | Description |
|---|---|---|
| vid | String | Video ID |
| basicInfo | Object | Video details See basicInfo Field Description |
| metaData | Object | Video metadata See metaData Field Description |
| transcodeInfos | Array | Video transcoding info list See transcodeInfos Field Description |
| snapshotInfo | Object | Video snapshot info See snapshotInfo Field Description |
basicInfo Field Description
| Field | Type | Description |
|---|---|---|
| title | String | Video title |
| description | String | Video description |
| duration | Long | Source video duration, in seconds |
| thumbnailURL | String | Thumbnail URL, small |
| coverURL | String | Cover URL, large |
| creationTime | String | Creation time, format: yyyy-MM-dd HH:mm:ss |
| updateTime | String | Update time, format: yyyy-MM-dd HH:mm:ss |
| size | Long | Source file size, in Bytes |
| status | Integer | Video status code |
| cateId | Long | Category ID; 1 is the root directory, i.e., "Default Category" |
| cateName | String | Category name |
| tags | String | Tags |
| uploader | String | Uploader |
| playTimes | Integer | Play count |
| md5Checksum | String | MD5 checksum of the source video file |
metaData Field Description
| Field | Type | Description |
|---|---|---|
| size | Long | Source file size, in Bytes |
| format | String | Video container type, e.g., mp4, flv |
| duration | Long | Source video duration, in seconds |
| bitrate | Integer | Video bitrate, in kbps |
| fps | Integer | Video frame rate |
| height | Integer | Resolution height, in px |
| width | Integer | Resolution width, in px |
| codec | String | Encoding format, e.g., h264, h265 |
transcodeInfos Field Description
| Field | Type | Description |
|---|---|---|
| playUrl | String | Playback URL |
| definition | String | Quality SOURCE: Original quality LD: Low definition SD: Standard definition HD: High definition |
| bitrate | Integer | Bitrate in kbps |
| duration | Long | Duration, in seconds |
| encrypt | Boolean | Whether encrypted true: Encrypted video false: Not encrypted |
| format | String | Transcoding format, e.g., mp4, flv, pdx, hls |
| fps | Integer | Video frame rate |
| height | Integer | Resolution height, in px |
| width | Integer | Resolution width, in px |
| status | String | Video status normal: Playable unavailable: Not playable |
snapshotInfo Field Description
| Field | Type | Description |
|---|---|---|
| imageUrl | String[] | Snapshot URL array, small |
| bigImageUrl | String[] | Snapshot URL array, large |
Java Request Example
For quick integration, download the relevant dependency source code. Click to download source code. After downloading, add it to your own source project. HttpUtil.java and VodSignUtil.java in the test cases are included in the download file.
It is strongly recommended to use the VOD Java SDK for API integration. The VOD Java SDK unifies and optimizes API call logic, exception handling, data signing, and HTTP request thread pools.
private static final Logger log = LoggerFactory.getLogger(VodSearchTest.class);
/**
* 搜索视频
* @throws Exception
* @throws NoSuchAlgorithmException
*/
@Test
public void testSearchVideo() throws Exception, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String secretKey = super.secretKey;
String userId = super.userId;
String ptime = String.valueOf(System.currentTimeMillis());
//业务参数
String url = "http://api.polyv.net/v2/video/search-videos";
String filters = "basicInfo,metaData";
String cateId = "1615795867474";
String uploader = "主账号";
String status = "60";
String containSubCate = "true";
String page = "1";
String pageSize = "10";
String sort = "creationTimeDesc";
Map<String, String> requestMap = new HashMap<>();
requestMap.put("userid", userId);
requestMap.put("ptime", ptime);
requestMap.put("cateId", cateId);
requestMap.put("filters", filters);
requestMap.put("uploader", uploader);
requestMap.put("status", status);
requestMap.put("containSubCate", containSubCate);
requestMap.put("page", page);
requestMap.put("pageSize", pageSize);
requestMap.put("sort", sort);
requestMap.put("sign", VodSignUtil.getSign(requestMap, secretKey));
String response = HttpUtil.get(url, requestMap);
log.debug("测试搜索视频,{}", response);
//do somethings
}
Response Example
See Global Error Description for system-wide error descriptions.
Success Example
{
"code": 200,
"status": "success",
"message": "success",
"data": {
"pageNumber": 1,
"totalPages": 1,
"pageSize": 10,
"contents": [
{
"vid": "1b448be32389acdf41f567e3a0bf0c19_1",
"basicInfo": {
"title": "3-25测试裁剪",
"description": "",
"duration": 81,
"coverURL": "https://img.videocc.net/uimage/1/1b448be323/9/1b448be32389acdf41f567e3a0bf0c19_0_b.jpg",
"creationTime": "2021-03-25 14:33:29",
"updateTime": "2021-03-25 14:35:22",
"size": 3101307,
"status": 61,
"cateId": 1616654004170,
"cateName": "fx20lh79cf",
"tags": "2191541_fx20lh79cf-2e77d0a29c11adbf9fea7a1a206fa666|ppt|playback",
"uploader": "API",
"playTimes": 1
},
"metaData": {
"size": 3101307,
"format": "m3u8",
"duration": 81,
"bitrate": 0,
"fps": 25,
"height": 720,
"width": 1280,
"codec": "h264"
}
},
{
"vid": "1b448be3230e2235bc8f43c3aafa23b5_1",
"basicInfo": {
"title": "合并后文件名1234",
"description": "",
"duration": 321,
"coverURL": "https://img.videocc.net/uimage/1/1b448be323/5/1b448be3230e2235bc8f43c3aafa23b5_0_b.jpg",
"creationTime": "2021-03-15 16:11:08",
"updateTime": "2021-03-15 16:16:21",
"size": 19117170,
"status": 61,
"cateId": 1615795867478,
"cateName": "fwr2dfsptr",
"tags": "2191541_fwr2dfsptr-b90e4e77230c24f895b1ffeabe3059cb|ppt|playback",
"uploader": "API",
"playTimes": 0
},
"metaData": {
"size": 19117170,
"format": "m3u8",
"duration": 321,
"bitrate": 0,
"fps": 25,
"height": 720,
"width": 1280,
"codec": "h264"
}
}
],
"totalItems": 2
}
}
Error Example
Incorrect signature
{
"code":400,
"status":"error",
"message":"the sign is not right",
"data":""
}
Timestamp expired
{
"code": 400,
"status": "error",
"message": "ptime is too old.",
"data": ""
}
Internal error, or invalid parameters passed, program conversion exception
{
"code": 500,
"status": "fail",
"message": "undefined error",
"data": null
}
