搜索视频

接口URL

http://api.polyv.net/v2/video/search-videos

接口说明

搜索视频

支持格式

JSON

请求方式

GET

请求数限制

TRUE

请求参数

参数名必选类型及范围说明

userid

string

用户ID

ptime

long

当前13位毫秒级时间戳,3分钟内有效

sign

String

签名,为40位大写的SHA1值【详见签名生成规则

filters

string

需要返回的视频信息,多个以英文逗号分隔,取值:basicInfo,metaData,transcodeInfo,snapshotInfo, 分别代表基础信息、元数据、转码信息、截图信息,默认仅返回基础信息

cateId

long

视频分类ID

title

string

按标题模糊搜索

tag

string

按视频标签模糊搜索

uploader

string

上传者

status

string

视频状态, 多个状态以英文逗号分隔,查询已发布状态的视频只需传61/60其中一个即可,如"61,50"

containSubCate

boolean

是否包含子分类, true:包含, false:不包含

startTime

long

按创建时间范围查询,起始时间戳,13位时间戳

endTime

long

结束时间戳,13位时间戳

encrypted

boolean

是否加密

playAuthEnable

boolean

是否开启了播放授权

sort

string

结果排序,可以按创建时间或播放次数降序/升序排序,取值:creationTimeAsc(创建时间升序)、creationTimeDesc(创建时间降序)、playTimesAsc(播放次数升序)、playTimesDesc(播放次数降序),默认按撞见时间升序排序

page

int

页码,默认为1

pageSize

int

页面大小,默认为10,最大1000

JSON示例

{
    "code": 200,
    "status": "success",
    "message": "success",
    "data": {
        "pageNumber": 1,
        "totalPages": 13,
        "pageSize": 1,
        "contents": [
            {
                "vid": "a2dc4f25173df1362065bd0d3732a30e_a",
                "basicInfo": {
                    "title": "a2dc4f25175d64f185bf631591fb08d0",
                    "description": "",
                    "duration": 78.0,
                    "coverURL": "https://img.videocc.net/uimage/a/a2dc4f2517/e/a2dc4xxxxxxxf1362065bd0d3732a30e_0_b.jpg",
                    "creationTime": "2021-04-16 11:50:34",
                    "updateTime": "2021-04-16 11:52:45",
                    "size": 36251552,
                    "status": 61,
                    "cateId": 1,
                    "cateName": "默认分类",
                    "tags": "",
                    "uploader": "主账号",
                    "playTimes": 1
                },
                "metaData": {
                    "size": 36251552,
                    "format": "mp4",
                    "duration": 78.0,
                    "bitrate": 3549,
                    "fps": 29,
                    "height": 720,
                    "width": 1280,
                    "codec": "h264"
                },
                "transcodeInfos": [
                    {
                        "playUrl": null,
                        "definition": "LD",
                        "bitrate": 548,
                        "duration": 78.0,
                        "encrypt": true,
                        "format": "pdx",
                        "fps": 29,
                        "height": 720,
                        "width": 1280,
                        "status": "normal"
                    },
                    {
                        "playUrl": "https://hls.videocc.net/a2dc4f2517/e/a2dc4xxxxxxxf1362065bd0d3732a30e_1.m3u8",
                        "definition": "LD",
                        "bitrate": 548,
                        "duration": 78.0,
                        "encrypt": true,
                        "format": "hls",
                        "fps": 29,
                        "height": 720,
                        "width": 1280,
                        "status": "normal"
                    },
                    {
                        "playUrl": null,
                        "definition": "SD",
                        "bitrate": 997,
                        "duration": 78.0,
                        "encrypt": true,
                        "format": "pdx",
                        "fps": 29,
                        "height": 720,
                        "width": 1280,
                        "status": "normal"
                    },
                    {
                        "playUrl": "https://hls.videocc.net/a2dc4f2517/e/a2dc4xxxxxxxf1362065bd0d3732a30e_2.m3u8",
                        "definition": "SD",
                        "bitrate": 997,
                        "duration": 78.0,
                        "encrypt": true,
                        "format": "hls",
                        "fps": 29,
                        "height": 720,
                        "width": 1280,
                        "status": "normal"
                    },
                    {
                        "playUrl": null,
                        "definition": "HD",
                        "bitrate": 1404,
                        "duration": 78.0,
                        "encrypt": true,
                        "format": "pdx",
                        "fps": 29,
                        "height": 720,
                        "width": 1280,
                        "status": "normal"
                    },
                    {
                        "playUrl": "https://hls.videocc.net/a2dc4f2517/e/a2dc4xxxxxxxf1362065bd0d3732a30e_3.m3u8",
                        "definition": "HD",
                        "bitrate": 1404,
                        "duration": 78.0,
                        "encrypt": true,
                        "format": "hls",
                        "fps": 29,
                        "height": 720,
                        "width": 1280,
                        "status": "normal"
                    }
                ],
                "snapshotInfo": {
                    "imageUrl": [
                        "https://img.videocc.net/uimage/a/a2dc4f2517/e/a2dc4xxxxxxxf1362065bd0d3732a30e_0.jpg",
                        "https://img.videocc.net/uimage/a/a2dc4f2517/e/a2dc4xxxxxxxf1362065bd0d3732a30e_1.jpg",
                        "https://img.videocc.net/uimage/a/a2dc4f2517/e/a2dc4f25173df1362065bd0d3732a30e_2.jpg",
                        "https://img.videocc.net/uimage/a/a2dc4f2517/e/a2dc4xxxxxxxf1362065bd0d3732a30e_3.jpg",
                        "https://img.videocc.net/uimage/a/a2dc4f2517/e/a2dc4xxxxxxxf1362065bd0d3732a30e_4.jpg",
                        "https://img.videocc.net/uimage/a/a2dc4f2517/e/a2dc4xxxxxxxf1362065bd0d3732a30e_5.jpg"
                    ]
                }
            }
        ],
        "totalItems": 13
    }
}

返回错误json

签名不正确
{
"code":400,
"status":"error",
"message":"the sign is not right",
"data":""
}
时间戳过期
{
"code":400,
"status":"error",
"message":"ptime is too old.",
"data":""
}
内部错误,或传了非法参数,程序转换异常
{
    "code": 500,
    "status": "fail",
    "message": "undefined error",
    "data": null
}

字段说明

字段说明

code

响应http状态码

status

状态

message

错误描述

data

返回数据

data.pageNumber

当前的页数

data.pageSize

每页条数

data.totalItems

总的条数

data.contents

结果列表

vid

视频id

basicInfo.title

视频标题

basicInfo.description

视频描述

basicInfo.duration

源视频时长,单位:秒

basicInfo.coverURL

首图地址,大图

basicInfo.creationTime

创建时间

basicInfo.updateTime

更新时间

basicInfo.size

源文件大小,单位:Bytes

basicInfo.status

视频状态码

basicInfo.cateId

分类id, 如1为根目录

basicInfo.cateName

分类名称

basicInfo.tags

标签

basicInfo.uploader

上传者

basicInfo.playTimes

视频播放次数

transcodeInfos.playUrl

播放地址

transcodeInfos.definition

清晰度,SOURCE:原清晰度,LD:普清,SD:标清,HD:高清

transcodeInfos.duration

时长,秒

transcodeInfos.encrypt

加密视频为true,非加密为false

transcodeInfos.format

转码格式,如mp4、flv、pdx、hls

transcodeInfos.fps

视频帧率

transcodeInfos.bitrate

码率kbps

transcodeInfos.height

分辨率高,单位:px

transcodeInfos.width

分辨率宽,单位:px

transcodeInfos.status

视频状态, normal:可以正常播放,unavailable:不能正常播放

metaData

源文件大小,单位:Bytes

metaData.size

源文件大小,单位:Bytes

metaData.format

视频容器类型,如mp4、flv等

metaData.duration

源视频时长,单位:秒

metaData.bitrate

视频码率,单位:bps

metaData.fps

视频帧率

metaData.height

分辨率高,单位:px

metaData.width

分辨率宽,单位:px

metaData.codec

编码格式,如h264、h265等

snapshotInfo.imageUrl

截图url数组

视频状态码status含义

60/61

已发布

10

等待编码

20

正在编码

50

等待审核

51

审核不通过

-1

已删除

### java请求示例

```java

@Test

public void testSearchVideos() throws Exception {
    String url = "http://api.polyv.net/v2/video/search-videos";
    long cateId = 1L;
    boolean containSubCate = true;
    String filters = "basicInfo,metaData,transcodeInfo,snapshotInfo";
    Map<String, String> params = new HashMap<>();
    params.put("userid", userid);
    params.put("filters", filters);
    params.put("containSubCate", String.valueOf(containSubCate));
    params.put("cateId", String.valueOf(cateId));
    params.put("ptime", String.valueOf(System.currentTimeMillis()));
    params.put("sign", getSign(params, secretkey));
    String response = HttpClientUtil.getInstance().sendHttpGet(url + "?" + PolyvTool.mapJoinNotEncode(params));
    System.out.println(response);
}






Last updated