Batch Query Video Duration and Size
Interface Description
1、根据分类id或者视频id批量查询视频的时长和大小
2、接口URL中的{userid}为点播账号userid,具体参考菜单【使用须知】->【获取密钥】
3、支持https协议
Interface URL
http://api.polyv.net/v2/video/{userid}/getSizeByCata
Request Method
GET
Interface Constraints
The interface supports both HTTP and HTTPS. HTTPS is recommended to ensure interface security. Interface calls have frequency limits. See details
Video ID and category ID cannot both be empty. If both are provided, the query will be based on the video ID, and the category ID will not take effect.
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| ptime | true | Long | Current time in milliseconds timestamp, valid for 3 minutes |
| sign | true | String | Signature, a 40-character uppercase SHA1 value. The secretkey used to generate the signature is critical for communication data security. It must never be used directly on the client side. All APIs must be called through the customer's own server to relay requests to the POLYV server for response data. See signature generation rules |
| vids | true | String | Video IDs, multiple videos separated by commas. Example: a2dc4f25179499d6586362672838cc2d_a,a2dc4f25179499d6586362672838cc2d_a. Maximum of 500 video IDs per request |
| cataid | false | String | Multiple category IDs separated by commas. Example: 23,34 |
Example
http://api.polyv.net/v2/video/1b448be323/getSizeByCata?vids=1b448be3239c2ef0cb3ab9fd105f7fb2_1,1b448be32399ac90f523f76c7430c9a5_1&sign=E89E543C0F731046620C3D1662F6967323349F27&ptime=1617098602701
Response Parameter Description
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Response status code. 200 indicates success, non-200 indicates failure. See global error description |
| status | String | Response status text |
| message | String | Response description. When code is 400 or 500, provides auxiliary error reason |
| data | Array | Returns channel details on success See data field description, returns empty on failure |
Data Parameter Description
| Field | Type | Description |
|---|---|---|
| cataid | Long | Category ID |
| videos | Array | Returns video result set array See videos field description |
videos Parameter Description
| Field | Type | Description |
|---|---|---|
| vid | String | Video ID |
| duration | String | Preview duration, e.g., 00:00:24 |
| filesize1 | Long | Size of encoded bitrate 1 FLV, in Bytes |
| filesize2 | Long | Size of encoded bitrate 2 FLV, in Bytes |
| filesize3 | Long | Size of encoded bitrate 3 FLV, in Bytes |
Java Request Example
For quick integration of basic code, please download the relevant dependency source code. Click to download source code. After downloading, add it to your own source project. The test cases include HttpUtil.java and VodSignUtil.java in the downloaded file.
It is strongly recommended to use the VOD Java SDK for API integration. The VOD Java SDK provides unified encapsulation and optimization for API call logic, exception handling, data signing, and HTTP request thread pools.
private static final Logger log = LoggerFactory.getLogger(VodVideoManageManagementTest.class);
/**
*批量查询视频时长和大小
*/
@Test
public void testBatchGetDurationAndSize() 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/"+userId+"/getSizeByCata";
String cataid="1615286323771";
//调用参数
Map<String, String> requestMap = new HashMap<>();
requestMap.put("userid", userId);
requestMap.put("ptime", ptime);
requestMap.put("cataid", cataid);
requestMap.put("sign", VodSignUtil.getSign(requestMap, secretKey));
String response = HttpUtil.get(url, requestMap);
log.debug("测试批量查询视频时长和大小,{}", response);
//do somethings
}
Response Example
For global system error descriptions, see Global Error Description
Success Example
{
"code":200,
"status":"success",
"message":"success",
"data":[
{
"cataid":1615286323771,
"videos":[
{
"vid":"1b448be323eb5bbbf0f47e303a54d536_1",
"duration":"00:00:10",
"filesize1":202978
},
{
"vid":"1b448be323be5ff7f8956437d102c4d8_1",
"duration":"00:00:24",
"filesize1":1168036,
"filesize2":1929455,
"filesize3":4062216
},
{
"vid":"1b448be32399ac90f523f76c7430c9a5_1",
"duration":"00:00:24",
"filesize1":1205029,
"filesize2":1986035,
"filesize3":4168438
},
{
"vid":"1b448be3239c2ef0cb3ab9fd105f7fb2_1",
"duration":"00:00:24",
"filesize1":1190625,
"filesize2":1985852,
"filesize3":4119734
}
]
}
]
}
Error Example
{
"code":400,
"status":"error",
"message":"sign can not be empty.",
"data":""
}
