Query Subtitle List
Updated: 2025-01-14 15:55:43
API Description
1、通过视频id获取视频字幕文件详情列表
2、接口URL中的{userid}为点播账号userid,具体参考菜单【使用须知】->【获取密钥】
3、接口支持https协议
API URL
http://api.polyv.net/v2/video/{userid}/srt/list
Request Method
GET
API Constraints
- The API supports both HTTP and HTTPS. HTTPS is recommended to ensure API security. API calls are subject to frequency limits. See details
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| ptime | true | Long | Current time in milliseconds timestamp, valid within 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 |
| vid | true | String | Video ID, e.g., 1b448be3235552e5fafb16489eb01839_1 |
Example
http://api.polyv.net/v2/video/1b448be323/srt/list?vid=1b448be323dec2a7bed6db61bd7d8a77_1&sign=0A3134D4A830F7F75EB13AFDC11FE91596B333CF&ptime=1617263522491
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 | Object | Returns subtitle file information on success [See Data field description](/vod/api/video_management/subtitle/get_subtitle.md?id=polyv1], returns empty on failure |
Data Parameter Description
| Parameter | Type | Description |
|---|---|---|
| srts | Array | Response result set See Srts field description |
Srts Parameter Description
| Parameter | Type | Description |
|---|---|---|
| rank | Integer | Subtitle file upload sequence number, starting from 1 |
| name | String | Subtitle file name |
| url | String | Subtitle file link |
Return Error Code List
| Error Code | message | Description |
|---|---|---|
| 400 | sign can not be empty. | Encryption string is empty |
| 400 | ptime is too old. | Timestamp has expired |
| 400 | ptime is illegal. | Timestamp parameter format is incorrect or exceeds current time by 3 minutes |
| 400 | Could not find user by userid. | User ID does not exist |
| 400 | the sign is not right. | Encryption string is incorrect |
| 401 | vid is blank. | Video ID is empty |
| 402 | cannot find the video. | Video not found |
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 code project. HttpUtil.java and VodSignUtil.java in the test cases are included 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(VodVideoSubtitleTest.class);
/**
* 查询字幕列表
*/
@Test
public void testGetSubtitle() 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+"/srt/list";
String vid = "1b448be323dec2a7bed6db61bd7d8a77_1";
Map<String, String> requestMap = new HashMap<>();
requestMap.put("ptime", ptime);
requestMap.put("vid", vid);
requestMap.put("sign", VodSignUtil.getSign(requestMap, secretKey));
String response = HttpUtil.get(url, requestMap);
log.debug("测试查询字幕列表,{}", response);
//do somethings
}
Response Example
For global error descriptions, see Global Error Description
Success Example
{
"code": 200,
"status": "success",
"message": "success",
"data": {
"srts": [{
"rank": 1,
"name": "测试字幕",
"url": "http://img.videocc.net/usrt/1/1b448be323/srt/9b6d1f68-c5e7-4a90-af1c-72ea23ab0a9c.srt"
}]
}
}
Error Example
{
"code": 400,
"status": "error",
"message": "ptime is too old.",
"data": ""
}
