搜尋影片
更新時間:2022-05-23 19:02:59
介面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請求範例
@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);
}
