> For the complete documentation index, see [llms.txt](https://polyv.gitbook.io/document/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://polyv.gitbook.io/document/docs/vod/api/sub-account/sub_search_video.md).

# 搜索视频

### 接口描述

```
1、通过子账号id，搜索视频
2、接口支持https协议
```

### 接口URL

```
http://api.polyv.net/v3/video/list-video
```

[在线API调用](https://git.polyv.net/help-center/document-center/-/blob/master/req.html?api=http:/api.polyv.net/v3/video/list-video/README.md)

### 请求方式

```
GET
```

### 接口约束

1、接口同时支持HTTP 、HTTPS ，建议使用HTTPS 确保接口安全，接口调用有频率限制，[详细请查看](https://git.polyv.net/help-center/document-center/-/blob/master/vod/api/limit/README.md)

### 请求参数描述

| 参数名            | 必选    | 类型      | 说明                                                                                                                                             |
| -------------- | ----- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| appId          | true  | String  | 保利威点播子账户appId，获取路径：保利威点播后台->设置->账号管理                                                                                                           |
| timestamp      | true  | Long    | 当前时间的毫秒级时间戳，3分钟内有效                                                                                                                             |
| sign           | true  | String  | 签名，32位大写MD5值【详见[MD5签名生成规则](https://git.polyv.net/help-center/document-center/-/blob/master/vod/api/buildSignMd5/README.md)】                    |
| cataId         | false | String  | 视频分类id，该参数获取自【[获取分类及子分类](https://git.polyv.net/help-center/document-center/-/blob/master/vod/api/video_management/category/get_categories.md)】 |
| title          | false | String  | 按标题搜索                                                                                                                                          |
| uploader       | false | String  | 上传者，例如：主账号                                                                                                                                     |
| status         | false | String  | 视频状态，可以参考【[status字段说明](https://git.polyv.net/help-center/document-center/-/blob/master/vod/api/sub_account/sub_search_video.md?id=status字段说明)】 |
| containSubCate | false | String  | <p>是否包含子分类<br>Y：包含<br>N：不包含</p>                                                                                                                |
| startTime      | false | Long    | <p>按创建时间范围查询，起始时间戳，13位时间戳<br>例如：1617866563834</p>                                                                                              |
| endTime        | false | Long    | 结束时间戳，13位时间戳，例如：1617866563834                                                                                                                  |
| page           | false | Integer | 页码，默认为1                                                                                                                                        |
| pageSize       | false | Integer | 页面大小，默认为10                                                                                                                                     |
| sort           | false | String  | <p>排序方式<br>creationTimeDesc：降序<br>creationTimeAsc：升序</p>                                                                                       |

#### status字段说明

| 视频状态码 | 说明    |
| ----- | ----- |
| 60/61 | 已发布   |
| 10    | 等待编码  |
| 20    | 正在编码  |
| 50    | 等待审核  |
| 51    | 审核不通过 |
| -1    | 已删除   |

### 示例

```requestUrl
http://api.polyv.net/v3/video/list-video?sign=13C80EAA5C93D1A62D197AFAF535D63F&pageSize=10&sort=creationTimeDesc&title=hello&uploader=%E4%B8%BB%E8%B4%A6%E5%8F%B7&appId=a0Wmol5EwX&containSubCate=Y&cataId=1617173363572&startTime=&endTime=&page=1&timestamp=1617937287873&status=60

```

### 响应参数描述

| 参数名       | 类型      | 说明                                                                                                                                                           |
| --------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| code      | Integer | 响应状态码，200为成功返回，非200为失败【详见[全局错误说明](https://git.polyv.net/help-center/document-center/-/blob/master/vod/api/errorInfo/README.md)】                              |
| status    | String  | 响应状态文本信息                                                                                                                                                     |
| requestId | String  | 本次请求的业务流水号，便于客户端/服务器端排查问题                                                                                                                                    |
| error     | Object  | 响应失败时返回错误的详细信息【详见[error字段说明](https://git.polyv.net/help-center/document-center/-/blob/master/vod/api/sub_account/sub_search_video.md?id=error字段说明)】，响应成功时返回空 |
| data      | Object  | 响应成功时返回搜索结果【详见[data字段说明](https://git.polyv.net/help-center/document-center/-/blob/master/vod/api/sub_account/sub_search_video.md?id=data字段说明)】，响应失败时返回空      |

#### error字段说明

| 字段   | 类型      | 说明                                                                                                            |
| ---- | ------- | ------------------------------------------------------------------------------------------------------------- |
| code | Integer | 错误码                                                                                                           |
| desc | String  | 错误描述【详见[全局错误说明](https://git.polyv.net/help-center/document-center/-/blob/master/vod/api/errorInfo/README.md)】 |

#### data字段说明

| 字段         | 类型      | 说明                                                                                                                                                   |
| ---------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| pageNumber | Integer | 当前的页数                                                                                                                                                |
| totalPages | Integer | 总的页数                                                                                                                                                 |
| totalItems | Integer | 总的条数                                                                                                                                                 |
| pageSize   | Integer | 每页条数                                                                                                                                                 |
| contents   | Array   | 搜索视频的结果列表【详见[contents字段说明](https://git.polyv.net/help-center/document-center/-/blob/master/vod/api/sub_account/sub_search_video.md?id=contents字段说明)】 |

#### contents字段说明

| 字段        | 类型     | 说明                                                                                                                                                    |
| --------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| vid       | String | 视频id                                                                                                                                                  |
| basicInfo | Object | 视频的详细信息 【详见[basicInfo字段说明](https://git.polyv.net/help-center/document-center/-/blob/master/vod/api/sub_account/sub_search_video.md?id=basicInfo字段说明)】 |

#### basicInfo字段说明

| 字段           | 类型      | 说明                   |
| ------------ | ------- | -------------------- |
| title        | String  | 视频标题                 |
| description  | String  | 视频描述                 |
| duration     | Long    | 源视频时长，单位：秒           |
| coverURL     | String  | 首图地址，大图              |
| creationTime | String  | 创建时间                 |
| updateTime   | String  | 更新时间                 |
| size         | Long    | 源文件大小，单位：Bytes       |
| status       | Integer | 视频状态码                |
| cateId       | Long    | 分类id；其中1为根目录，即"默认分类" |
| cateName     | String  | 分类名称                 |
| tags         | String  | 标签                   |
| uploader     | String  | 上传者                  |

### Java请求示例

快速接入基础代码请下载相关依赖源码， [点击下载源代码](https://git.polyv.net/help-center/document-center/-/blob/master/third_res/util.zip) ,下载后加入到自己的源码工程中即可。测试用例中的**HttpUtil.java 和 VodSignUtil.java** 都包含在下载文件中。

> 强烈建议您使用[点播Java SDK](https://git.polyv.net/help-center/document-center/-/blob/master/vod/java/README.md)完成API的功能对接，点播Java SDK 对API调用逻辑、异常处理、数据签名、HTTP请求线程池进行了统一封装和优化。

```java
private static final Logger log = LoggerFactory.getLogger(VodSubAccountTest.class);

/**
 * 搜索视频
 * @throws Exception
 * @throws NoSuchAlgorithmException
 */
@Test
public void testSearchSubVideo() throws Exception, NoSuchAlgorithmException {
        //公共参数,填写自己的实际参数
        String appId = super.appId;
        String appSecret = super.appSecret;
        String timestamp = String.valueOf(System.currentTimeMillis());

        //业务参数
        String url = "http://api.polyv.net/v3/video/list-video";
        String cataId = "1617173363572";
        String title = "hello";
        String uploader = "主账号";
        String status = "60";
        String containSubCate = "Y";
        String startTime = "";
        String endTime = "";
        String page = "1";
        String pageSize = "10";
        String sort = "creationTimeDesc";

        Map<String, String> requestMap = new HashMap<>();
        requestMap.put("appId", appId);
        requestMap.put("timestamp", timestamp);
        requestMap.put("cataId", cataId);
        requestMap.put("title", title);
        requestMap.put("uploader", uploader);
        requestMap.put("status", status);
        requestMap.put("containSubCate", containSubCate);
        requestMap.put("startTime", startTime);
        requestMap.put("endTime", endTime);
        requestMap.put("page", page);
        requestMap.put("pageSize", pageSize);
        requestMap.put("sort", sort);

        //用md5进行签名，使用子账号的secretKey签名
        requestMap.put("sign", VodSignUtil.getSignMd5(requestMap, appSecret));
        String response = HttpUtil.get(url, requestMap);
        log.debug("测试搜索视频,{}", response);
        //do somethings
}

```

### 响应示例

系统全局错误说明详见[全局错误说明](https://git.polyv.net/help-center/document-center/-/blob/master/vod/api/errorInfo/README.md)

成功示例

```json
{
  "requestId": "c271194e-c7b7-43e7-a81e-c2edb7d9c2d2",
  "code": 200,
  "status": "success",
  "error": null,
  "data": {
    "pageNumber": 1,
    "totalPages": 1,
    "pageSize": 10,
    "contents": [
      {
        "vid": "1b448be323a6a1a6c0c237856f555e88_1",
        "basicInfo": {
          "title": "hello,word",
          "description": "",
          "duration": 24,
          "coverURL": "https://img.videocc.net/uimage/1/http://img.videocc.net/uimage/1/1b448be323/first_image/7b56e5d7-8aae-4e65-8d43-cd550ccff409_b.png",
          "creationTime": "2021-04-01 10:52:07",
          "updateTime": "2021-04-02 09:31:00",
          "size": 7156046,
          "status": 61,
          "cateId": 1615536384688,
          "cateName": "Junit测试(勿删)_3",
          "tags": "test",
          "uploader": "主账号"
        }
      }
    ],
    "totalItems": 1
  }
}

```

异常示例

```json
{
    "requestId": "0fefcb4a-1949-4145-a350-3ec941e7daff", 
    "code": 400, 
    "status": "error", 
    "error": {
        "code": 1112, 
        "desc": "param is not number: status"
    }, 
    "data": null
}

```
