syncService
1. Query Video Sync List
Description
分页查询视频同步列表
接口地址(仅做说明使用):https://api.polyv.net/v2/video/grab/%s/list
Call Constraints
- API calls are rate-limited. See details. For common call exceptions, see details.
Unit Test
@Test
public void testGetTaskList() throws IOException, NoSuchAlgorithmException {
VodGetTaskListRequest vodGetTaskListRequest = new VodGetTaskListRequest();
VodGetTaskListResponse vodGetTaskListResponse = null;
try {
vodGetTaskListRequest.setCurrentPage(1).setPageSize(10);
vodGetTaskListResponse = new VodSyncServiceImpl().getTaskList(vodGetTaskListRequest);
Assert.assertNotNull(vodGetTaskListResponse);
if (vodGetTaskListResponse != null) {
log.debug("测试分页查询视频同步列表成功,{}", JSON.toJSONString(vodGetTaskListResponse));
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Test Description
On a correct request, a
VodGetTaskListResponseobject is returned. The B-side processes business logic based on this object.If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message is available viaPloyvSdkException.getMessage(), e.g., [Input parameter [xxx.chat.VodxxxRequest] object validation failed, failed field [pic cannot be empty / msg cannot be empty]].If the server encounters an error, a
PloyvSdkExceptionis thrown. The error message is available viaPloyvSdkException.getMessage(), e.g., [Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]
Request Parameter Description
| Parameter Name | Required | Type | Description |
|---|---|---|---|
| currentPage | false | Integer | Page number, defaults to 1 [Corresponds to the page field in the API documentation] |
| pageSize | false | Integer | Number of data items per page, defaults to 20 |
Return Object Description
| Parameter Name | Type | Description |
|---|---|---|
| contents | Array | Query result list [See Task Parameter Description for details] |
| pageSize | Integer | Number of data items per page, defaults to 20 |
| currentPage | Integer | Current page [Corresponds to the pageNumber field in the API documentation] |
| totalItems | Integer | Total number of records |
| totalPage | Integer | Total number of pages [Corresponds to the totalPages field in the API documentation] |
Task Parameter Description
| Parameter Name | Type | Description |
|---|---|---|
| taskId | String | Sync task ID [Corresponds to the taskid field in the API documentation] |
| userId | String | Vod user ID [Corresponds to the userid field in the API documentation] |
| originalName | String | Title of the uploaded sync task CSV file [Corresponds to the originalname field in the API documentation] |
| fileUrl | String | CSV file URL for the sync task [Corresponds to the fileurl field in the API documentation] |
| successCount | Integer | Number of successful syncs [Corresponds to the seccesscount field in the API documentation] |
| totalCount | Integer | Total syncs in this task [Corresponds to the totalcount field in the API documentation] |
| failCount | Integer | Number of failed syncs [Corresponds to the failcount field in the API documentation] |
| status | String | Sync task completion status |
| endTime | Date | Task completion time, format: yyyy-MM-dd HH:mm:ss [Corresponds to the endtime field in the API documentation] |
| createTime | Date | Task creation time, format: yyyy-MM-dd HH:mm:ss [Corresponds to the createtime field in the API documentation] |
2. Delete Sync Video Task
Description
通过视频同步任务id删除同步视频任务
接口地址(仅做说明使用):https://api.polyv.net/v2/video/grab/%s/delete
Call Constraints
- API calls are rate-limited. See details. For common call exceptions, see details.
Unit Test
@Test
public void testDeleteTask() throws IOException, NoSuchAlgorithmException {
VodDeleteTaskRequest vodDeleteTaskRequest = new VodDeleteTaskRequest();
Boolean vodDeleteTaskResponse = null;
try {
//准备测试数据
VodGetTaskListResponse.Task task = super.getTask(true);
vodDeleteTaskRequest.setTaskId(task.getTaskId());
vodDeleteTaskResponse = new VodSyncServiceImpl().deleteTask(vodDeleteTaskRequest);
Assert.assertTrue(vodDeleteTaskResponse);
if (vodDeleteTaskResponse) {
log.debug("测试删除同步视频任务成功");
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Test Description
On a correct request, a
Booleanobject is returned. The B-side processes business logic based on this object.If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message is available viaPloyvSdkException.getMessage(), e.g., [Input parameter [xxx.chat.VodxxxRequest] object validation failed, failed field [pic cannot be empty / msg cannot be empty]].If the server encounters an error, a
PloyvSdkExceptionis thrown. The error message is available viaPloyvSdkException.getMessage(), e.g., [Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]
Request Parameter Description
| Parameter Name | Required | Type | Description |
|---|---|---|---|
| taskId | true | String | Sync task ID |
Return Object Description
true indicates successful deletion, false indicates failure.
3. Export Video Sync Task
Description
通过视频同步任务id导出视频同步任务
接口地址(仅做说明使用):https://api.polyv.net/v2/video/grab/%s/listVideos/export
Call Constraints
- API calls are rate-limited. See details. For common call exceptions, see details.
Unit Test
@Test
public void testExportTask() throws Exception, NoSuchAlgorithmException {
VodExportTaskRequest vodExportTaskRequest = new VodExportTaskRequest();
byte[] vodExportTaskResponse = null;
try {
//准备测试数据
VodGetTaskListResponse.Task task = super.getTask(false);
//path设置为下载文件路径
String path = Paths.get(getClass().getResource("/file/").toURI()).toString() + "download.csv";
vodExportTaskRequest.setTaskId(task.getTaskId());
vodExportTaskResponse = new VodSyncServiceImpl().exportTask(vodExportTaskRequest);
Assert.assertNotNull(vodExportTaskResponse);
if (vodExportTaskResponse != null) {
FileUtil.writeFile(vodExportTaskResponse, path);
log.debug("测试导出视频同步任务成功,文件长度{}", vodExportTaskResponse.length);
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Test Description
On a correct request, a
byte[]object is returned. The B-side processes business logic based on this object.If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message is available viaPloyvSdkException.getMessage(), e.g., [Input parameter [xxx.chat.VodxxxRequest] object validation failed, failed field [pic cannot be empty / msg cannot be empty]].If the server encounters an error, a
PloyvSdkExceptionis thrown. The error message is available viaPloyvSdkException.getMessage(), e.g., [Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]
Request Parameter Description
| Parameter Name | Required | Type | Description |
|---|---|---|---|
| taskId | true | String | Sync task ID |
Return Object Description
The returned byte[] can be saved as shown in the unit test example, or handled as needed.
