Polyv Help Center

Help Center

Query Screenshot Task Status

Updated: 2025-01-14 16:06:19

API Description

1、通过任务id获取截图任务的状态
2、接口URL中的{userid}为点播账号userid,具体参考菜单【使用须知】->【获取密钥】
3、接口支持https协议

API URL

http://api.polyv.net/v2/video/snapshot/{userid}/getTaskStatus

Online API Call

Request Method

GET

API Constraints

  1. The API supports both HTTP and HTTPS. HTTPS is recommended for security. API calls have frequency limits. See details

Request Parameter Description

Parameter Required Type Description
ptime true Long Current time in milliseconds, 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 not be stored or 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
taskId true String Task ID [Can be obtained via Capture Screenshot at Video Timestamp]

Example

http://api.polyv.net/v2/video/snapshot/1b448be323/getTaskStatus?sign=67B7C378A673CE9742A45FD362DB2F68A173E39C&ptime=1617702097746&taskId=2036

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 additional error details
data Object Detailed screenshot task status See data field description

data Parameter Description

Field Type Description
taskId Integer Task ID
userId String POLYV VOD account ID. Refer to Get Secret Key for retrieval. Path: Official Website -> Login -> VOD (API Interface)
vid String Video ID
status String Task status
waiting: Waiting for screenshot
processing: Screenshot processing
success: Task successful
fail: Task failed
createTime Integer Task creation time, 13-digit millisecond timestamp
beginProcessTime Integer Screenshot start time, 13-digit millisecond timestamp. 0 if task has not started
finishProcessTime Integer Screenshot completion time, 13-digit millisecond timestamp. 0 if task is not completed
snapshots Array Screenshot information array. Empty array if task failed or has not started See snapshots parameter description

snapshots Parameter Description

Field Type Description
offsetTime Integer Screenshot timestamp
imageUrl String Screenshot URL

Error Code List

Error Code Message Description
400 sign can not be empty. Signature is empty
400 vid invalid. Invalid video vid
400 ptime is too old. Timestamp expired
400 ptime is illegal. Invalid timestamp format 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. Incorrect signature
400 task not found Task not found

Java Request Example

For quick integration, 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(VodSnapshotTest.class);
/**
 * 获取截图任务状态
 * @throws Exception
 * @throws NoSuchAlgorithmException
 */
@Test
public void testGetSnapshotTask() throws Exception, NoSuchAlgorithmException {
    //公共参数,填写自己的实际参数
    String secretKey = super.secretKey;
    String userId = super.userId;
    String ptime = String.valueOf(System.currentTimeMillis());
    //业务参数
    String url = String.format("http://api.polyv.net/v2/video/snapshot/%s/getTaskStatus", userId);
    String taskId = "2036";
    
    Map<String, String> requestMap = new HashMap<>();
    requestMap.put("ptime", ptime);
    requestMap.put("taskId", taskId);
    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": {
        "taskId": 2036,
        "userId": "1b448be323",
        "vid": "1b448be32303e4922a8f70d6b48220ae_1",
        "status": "success",
        "createTime": 1617700207000,
        "beginProcessTime": 1617700208000,
        "finishProcessTime": 1617700260000,
        "snapshots": [
            {
                "offsetTime": 5,
                "imageUrl": "http://vod-assets.videocc.net/snapshot/1b448be323/1b448be32303e4922a8f70d6b48220ae/5.jpg"
            },
            {
                "offsetTime": 10,
                "imageUrl": "http://vod-assets.videocc.net/snapshot/1b448be323/1b448be32303e4922a8f70d6b48220ae/10.jpg"
            },
            {
                "offsetTime": 15,
                "imageUrl": "http://vod-assets.videocc.net/snapshot/1b448be323/1b448be32303e4922a8f70d6b48220ae/15.jpg"
            },
            {
                "offsetTime": 20,
                "imageUrl": "http://vod-assets.videocc.net/snapshot/1b448be323/1b448be32303e4922a8f70d6b48220ae/20.jpg"
            }
        ]
    }
}

Error Example

Task not found

{
    "code": 400,
    "status": "error",
    "message": "task not found",
    "data": ""
}
联系客服,在线咨询