playListService
1. Create Playlist
Description
通过标题创建播放列表
接口地址(仅做说明使用):https://api.polyv.net/v2/play-list/create
Call Constraints
- API calls are rate-limited. Click for details. For common call exceptions, click here.
Unit Test
@Test
public void testCreatePlayList() throws IOException, NoSuchAlgorithmException {
VodCreatePlayListRequest vodCreatePlayListRequest = new VodCreatePlayListRequest();
VodCreatePlayListResponse vodCreatePlayListResponse = null;
try {
vodCreatePlayListRequest.setTitle("测试播放列表Junit").setDescription("测试描述信息").setTag("测试标签");
vodCreatePlayListResponse = new VodPlayListServiceImpl().createPlayList(vodCreatePlayListRequest);
Assert.assertNotNull(vodCreatePlayListResponse);
if (vodCreatePlayListResponse != null) {
log.debug("测试创建播放列表成功,{}", JSON.toJSONString(vodCreatePlayListResponse));
}
} 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 successful request, a
VodCreatePlayListResponseobject is returned. The B-end processes business logic based on this object.If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message can be found viaPloyvSdkException.getMessage(), e.g., [Validation failed for input parameter [xxx.chat.VodxxxRequest] object, failed fields [pic cannot be empty / msg cannot be empty]].If the server encounters an error, a
PloyvSdkExceptionis thrown. The error message can be found viaPloyvSdkException.getMessage(), e.g., [Error returned from Polyv request data, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| title | true | String | Title |
| description | false | String | Description |
| tag | false | String | Tag |
Response Object Description
| Parameter | Type | Description |
|---|---|---|
| playListId | String | Playlist ID |
2. Update Playlist Information
Description
通过播放列表id修改播放列表信息
接口地址(仅做说明使用):https://api.polyv.net/v2/play-list/update
Call Constraints
- API calls are rate-limited. Click for details. For common call exceptions, click here.
Unit Test
@Test
public void testUpdatePlayList() throws IOException, NoSuchAlgorithmException {
VodUpdatePlayListRequest vodUpdatePlayListRequest = new VodUpdatePlayListRequest();
VodUpdatePlayListResponse vodUpdatePlayListResponse = null;
try {
vodUpdatePlayListRequest.setPlayListId("1616396785347").setTitle("测试播放列表(Junit测试_勿删)").setTag("测试标签");
vodUpdatePlayListResponse = new VodPlayListServiceImpl().updatePlayList(vodUpdatePlayListRequest);
Assert.assertNotNull(vodUpdatePlayListResponse);
if (vodUpdatePlayListResponse != null) {
log.debug("测试修改播放列表信息成功,{}", JSON.toJSONString(vodUpdatePlayListResponse));
}
} 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 successful request, a
VodUpdatePlayListResponseobject is returned. The B-end processes business logic based on this object.If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message can be found viaPloyvSdkException.getMessage(), e.g., [Validation failed for input parameter [xxx.chat.VodxxxRequest] object, failed fields [pic cannot be empty / msg cannot be empty]].If the server encounters an error, a
PloyvSdkExceptionis thrown. The error message can be found viaPloyvSdkException.getMessage(), e.g., [Error returned from Polyv request data, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| playListId | true | String | Playlist ID |
| title | true | String | Title |
| description | false | String | Description |
| tag | false | String | Tag |
Response Object Description
| Parameter | Type | Description |
|---|---|---|
| playListId | String | Playlist ID |
3. Query Playlist Information
Description
通过播放列表id查询播放列表信息或查询所有播放列表
接口地址(仅做说明使用):https://api.polyv.net/v2/play-list/list
Call Constraints
- API calls are rate-limited. Click for details. For common call exceptions, click here.
Unit Test
@Test
public void testGetPlayListInfo() throws IOException, NoSuchAlgorithmException {
VodGetPlayListInfoRequest vodGetPlayListInfoRequest = new VodGetPlayListInfoRequest();
VodGetPlayListInfoResponse vodGetPlayListInfoResponse = null;
try {
vodGetPlayListInfoRequest.setPlayListIds("1602299692290,1602299700661");
vodGetPlayListInfoResponse = new VodPlayListServiceImpl().getPlayListInfo(vodGetPlayListInfoRequest);
Assert.assertNotNull(vodGetPlayListInfoResponse);
if (vodGetPlayListInfoResponse != null) {
log.debug("测试查询播放列表信息成功,{}", JSON.toJSONString(vodGetPlayListInfoResponse));
}
} 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 successful request, a
VodGetPlayListInfoResponseobject is returned. The B-end processes business logic based on this object.If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message can be found viaPloyvSdkException.getMessage(), e.g., [Validation failed for input parameter [xxx.chat.VodxxxRequest] object, failed fields [pic cannot be empty / msg cannot be empty]].If the server encounters an error, a
PloyvSdkExceptionis thrown. The error message can be found viaPloyvSdkException.getMessage(), e.g., [Error returned from Polyv request data, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| playListIds | false | String | Playlist IDs, separated by commas for multiple entries, max 1000, e.g., "1620153765497,1620142496099" |
| title | false | String | Title, fuzzy search by title |
| 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 |
Response Object Description
| Parameter | Type | Description |
|---|---|---|
| contents | Array | Paginated data [See Content 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] |
Content Parameter Description
| Parameter | Type | Description |
|---|---|---|
| id | Long | Playlist ID |
| description | String | Playlist description |
| tag | String | Playlist tag |
| title | String | Playlist title |
| creationTime | Date | Playlist creation time, format: yyyy-MM-dd HH:mm:ss |
| updateTime | Date | Playlist last update time, format: yyyy-MM-dd HH:mm:ss |
| videoCount | Integer | Number of videos in the playlist |
| videoList | Array | Videos in the playlist [See VideoList Parameter Description for details] |
VideoList Parameter Description
| Parameter | Type | Description |
|---|---|---|
| vid | String | Video vid |
| title | String | Video title |
| duration | Float | Video duration, in seconds |
| coverURL | String | Video cover image URL |
4. Add Video to Playlist
Description
通过视频id添加视频至播放列表
接口地址(仅做说明使用):https://api.polyv.net/v2/play-list/add-video
Call Constraints
- API calls are rate-limited. Click for details. For common call exceptions, click here.
Unit Test
@Test
public void testAddVideoToPlayList() throws IOException, NoSuchAlgorithmException {
VodAddVideoToPlayListRequest vodAddVideoToPlayListRequest = new VodAddVideoToPlayListRequest();
Boolean vodAddVideoToPlayListResponse = null;
try {
vodAddVideoToPlayListRequest.setPlayListId("1616396785347")
.setVideoId("1b448be32345b255cabc3fe8d65a4d00_1");
vodAddVideoToPlayListResponse = new VodPlayListServiceImpl().addVideoToPlayList(
vodAddVideoToPlayListRequest);
Assert.assertTrue(vodAddVideoToPlayListResponse);
if (vodAddVideoToPlayListResponse) {
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 successful request, a
Booleanobject is returned. The B-end processes business logic based on this object.If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message can be found viaPloyvSdkException.getMessage(), e.g., [Validation failed for input parameter [xxx.chat.VodxxxRequest] object, failed fields [pic cannot be empty / msg cannot be empty]].If the server encounters an error, a
PloyvSdkExceptionis thrown. The error message can be found viaPloyvSdkException.getMessage(), e.g., [Error returned from Polyv request data, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| playListId | true | String | Playlist ID |
| videoId | true | String | Video ID [Corresponds to the vid field in the API documentation] |
Response Object Description
null
5. Remove Video from Playlist
Description
通过视频id将视频从播放列表移除
接口地址(仅做说明使用):https://api.polyv.net/v2/play-list/remove-video
Call Constraints
- API calls are rate-limited. Click for details. For common call exceptions, click here.
Unit Test
@Test
public void testRemoveVideoFromPlayList() throws IOException, NoSuchAlgorithmException {
VodRemoveVideoFromPlayListRequest vodRemoveVideoFromPlayListRequest = new VodRemoveVideoFromPlayListRequest();
Boolean vodRemoveVideoFromPlayListResponse = null;
try {
//准备测试数据
super.addVideoToPlayListOther();
vodRemoveVideoFromPlayListRequest.setPlayListId("1616396785347")
.setVideoId(super.getTestVideoId());
vodRemoveVideoFromPlayListResponse = new VodPlayListServiceImpl().removeVideoFromPlayList(
vodRemoveVideoFromPlayListRequest);
Assert.assertTrue(vodRemoveVideoFromPlayListResponse);
if (vodRemoveVideoFromPlayListResponse) {
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 successful request, a
Booleanobject is returned. The B-end processes business logic based on this object.If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message can be found viaPloyvSdkException.getMessage(), e.g., [Validation failed for input parameter [xxx.chat.VodxxxRequest] object, failed fields [pic cannot be empty / msg cannot be empty]].If the server encounters an error, a
PloyvSdkExceptionis thrown. The error message can be found viaPloyvSdkException.getMessage(), e.g., [Error returned from Polyv request data, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| playListId | true | String | Playlist ID |
| videoId | true | String | Video ID [Corresponds to the vid field in the API documentation] |
Response Object Description
null
