Polyv Help Center

Help Center

categoryService

Updated: 2025-06-24 15:26:26

1. Create Video Category

Description

通过分类名称与上级分类目录id新建视频分类
接口地址(仅做说明使用):https://api.polyv.net/v2/video/%s/addCata

Call Constraints

  1. API calls are rate-limited. Click for details. For common call exceptions, click here.

Unit Test

    @Test
    public void testCreateCategory() throws IOException, NoSuchAlgorithmException {
        VodCreateCategoryRequest vodCreateCategoryRequest = new VodCreateCategoryRequest();
        VodCreateCategoryResponse vodCreateCategoryResponse = null;
        try {
            vodCreateCategoryRequest.setCategoryName("Junit测试")
                    .setParentId("1");
            vodCreateCategoryResponse = new VodCategoryServiceImpl().createCategory(vodCreateCategoryRequest);
            Assert.assertNotNull(vodCreateCategoryResponse);
            if (vodCreateCategoryResponse != null) {
                log.debug("测试新建视频分类成功,{}", vodCreateCategoryResponse);
            }
        } 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

  1. On a successful request, a VodCreateCategoryResponse object is returned. The B-end processes business logic based on this object.
  2. If request parameter validation fails, a PloyvSdkException is thrown. The error message can be obtained via PloyvSdkException.getMessage(), e.g., [Validation failed for input parameter [xxx.chat.VodxxxRequest] object, failed fields: [pic cannot be empty / msg cannot be empty]].
  3. If the server encounters an exception, a PloyvSdkException is thrown. The error message can be obtained via PloyvSdkException.getMessage(), e.g., [Error returned from Polyv request, request ID: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]

Request Parameter Description

Parameter Name Required Type Description
categoryName true String Category name, no more than 40 characters [Corresponds to API field cataname]
parentId true String The parent directory ID for the new category. A value of 1 indicates the root directory [Corresponds to API field parentid]

Response Object Description

Parameter Name Type Description
categoryId String The ID of the newly created category [Corresponds to API field cataid]
categoryTree String The tree path of the newly created category, comma-separated (half-width), e.g., 1b8be3,239c2e [Corresponds to API field catatree]






2. Query Video Category

Description

通过分类id查询分类下的树结构信息,含父子节点信息
接口地址(仅做说明使用):https://api.polyv.net/v2/video/%s/cataJson

Call Constraints

  1. API calls are rate-limited. Click for details. For common call exceptions, click here.

Unit Test

    @Test
    public void testGetCategory() throws IOException, NoSuchAlgorithmException {
        VodGetCategoryRequest vodGetCategoryRequest = new VodGetCategoryRequest();
        List<VodGetCategoryResponse> vodGetCategoryResponseList = null;
        try {
            vodGetCategoryRequest.setCategoryId("1");
            vodGetCategoryResponseList = new VodCategoryServiceImpl().getCategory(vodGetCategoryRequest);
            Assert.assertNotNull(vodGetCategoryResponseList);
            if (vodGetCategoryResponseList != null) {
                log.debug("测试查询视频分类成功,{}", JSON.toJSONString(vodGetCategoryResponseList));
            }
        } 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

  1. On a successful request, a VodGetCategoryResponse object is returned. The B-end processes business logic based on this object.
  2. If request parameter validation fails, a PloyvSdkException is thrown. The error message can be obtained via PloyvSdkException.getMessage(), e.g., [Validation failed for input parameter [xxx.chat.VodxxxRequest] object, failed fields: [pic cannot be empty / msg cannot be empty]].
  3. If the server encounters an exception, a PloyvSdkException is thrown. The error message can be obtained via PloyvSdkException.getMessage(), e.g., [Error returned from Polyv request, request ID: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]

Request Parameter Description

Parameter Name Required Type Description
categoryId false String Category ID. Defaults to the root directory. Retrieves the tree structure under this category [Corresponds to API field cataid]

Response Object Description

The response is a List<VodGetCategoryResponse>. The specific elements of VodGetCategoryResponse are as follows:

Parameter Name Type Description
text String Combination of category name and total video count under this category, e.g., Test Category (4)
categoryName String Category name [Corresponds to API field cataname]
categoryTree String Category tree, showing the category IDs from the root directory to this directory, e.g., 1,1474873756622 [Corresponds to API field catatree]
categoryId String Category ID. If it is 1, it is the root directory [Corresponds to API field cataid]
parentId String Parent category ID. The parent ID of the root directory is 0 [Corresponds to API field parentid]
videoNums Integer Total number of videos in this category and its subcategories [Corresponds to API field videos]
categoryProfile String First-level category settings information, including: encryption, watermark, courseware optimization, source file playback. Example: encryption [Corresponds to API field cataProfile]
nodes Array Subcategories of this category [See VodGetCategoryResponse Parameter Description]






3. Query Category Used Space

Description

通过分类id查询分类目录的使用空间
接口地址(仅做说明使用):https://api.polyv.net/v2/cata/size

Call Constraints

  1. API calls are rate-limited. Click for details. For common call exceptions, click here.

Unit Test

    @Test
    public void testGetCategorySize() throws IOException, NoSuchAlgorithmException {
        VodGetCategorySizeRequest vodGetCategorySizeRequest = new VodGetCategorySizeRequest();
        Long vodGetCategorySizeResponse = null;
        try {
            vodGetCategorySizeRequest.setCategoryId("1602671097888");
            vodGetCategorySizeResponse = new VodCategoryServiceImpl().getCategorySize(vodGetCategorySizeRequest);
            Assert.assertNotNull(vodGetCategorySizeResponse);
            if (vodGetCategorySizeResponse != null) {
                log.debug("测试通过分类ID查询目录使用空间成功");
            }
        } 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

  1. On a successful request, a Long object is returned. The B-end processes business logic based on this object.
  2. If request parameter validation fails, a PloyvSdkException is thrown. The error message can be obtained via PloyvSdkException.getMessage(), e.g., [Validation failed for input parameter [xxx.chat.VodxxxRequest] object, failed fields: [pic cannot be empty / msg cannot be empty]].
  3. If the server encounters an exception, a PloyvSdkException is thrown. The error message can be obtained via PloyvSdkException.getMessage(), e.g., [Error returned from Polyv request, request ID: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]

Request Parameter Description

Parameter Name Required Type Description
categoryId true String Category directory ID. (id=1 indicates the default category) [Corresponds to API field cataid]

Response Object Description

The size of videos under the category, in bytes.




4. Modify Category Name

Description

通过分类id修改分类名称
接口地址(仅做说明使用):https://api.polyv.net/v2/video/%s/updateCata

Call Constraints

  1. API calls are rate-limited. Click for details. For common call exceptions, click here.

Unit Test

    @Test
    public void testUpdateCategoryName() throws IOException, NoSuchAlgorithmException {
        VodUpdateCategoryNameRequest vodUpdateCategoryNameRequest = new VodUpdateCategoryNameRequest();
        Boolean vodUpdateCategoryNameResponse = null;
        try {
            vodUpdateCategoryNameRequest.setCategoryId("1615536384688")
                    .setCategoryName("Junit测试(勿删)_3");
            vodUpdateCategoryNameResponse = new VodCategoryServiceImpl().updateCategoryName(
                    vodUpdateCategoryNameRequest);
            Assert.assertTrue(vodUpdateCategoryNameResponse);
            if (vodUpdateCategoryNameResponse) {
                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

  1. On a successful request, a Boolean object is returned. The B-end processes business logic based on this object.
  2. If request parameter validation fails, a PloyvSdkException is thrown. The error message can be obtained via PloyvSdkException.getMessage(), e.g., [Validation failed for input parameter [xxx.chat.VodxxxRequest] object, failed fields: [pic cannot be empty / msg cannot be empty]].
  3. If the server encounters an exception, a PloyvSdkException is thrown. The error message can be obtained via PloyvSdkException.getMessage(), e.g., [Error returned from Polyv request, request ID: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]

Request Parameter Description

Parameter Name Required Type Description
categoryId true String Category ID [Corresponds to API field cataid]
categoryName true String The modified category name [Corresponds to API field cataname]

Response Object Description

true indicates modification success, false indicates modification failure.




5. Modify Category Properties

Description

通过分类id修改分类属性
接口地址(仅做说明使用):https://api.polyv.net/v2/video/%s/updateCataProfile

Call Constraints

  1. API calls are rate-limited. Click for details. For common call exceptions, click here.

Unit Test

    @Test
    public void testUpdateCategoryProfile() throws IOException, NoSuchAlgorithmException {
        VodUpdateCategoryProfileRequest vodUpdateCategoryProfileRequest = new VodUpdateCategoryProfileRequest();
        Boolean vodUpdateCategoryProfileResponse = null;
        try {
            vodUpdateCategoryProfileRequest.setCategoryId("1615536384688")
                    .setIsSettings("Y")
                    .setKeepSource(0)
                    .setEncrypt(0)
                    .setHlsLevel("open")
                    .setIsEdu(0)
                    .setEncodeAAC(0);
            vodUpdateCategoryProfileResponse = new VodCategoryServiceImpl().updateCategoryProfile(
                    vodUpdateCategoryProfileRequest);
            Assert.assertTrue(vodUpdateCategoryProfileResponse);
            if (vodUpdateCategoryProfileResponse) {
                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

  1. On a successful request, a Boolean object is returned. The B-end processes business logic based on this object.
  2. If request parameter validation fails, a PloyvSdkException is thrown. The error message can be obtained via PloyvSdkException.getMessage(), e.g., [Validation failed for input parameter [xxx.chat.VodxxxRequest] object, failed fields: [pic cannot be empty / msg cannot be empty]].
  3. If the server encounters an exception, a PloyvSdkException is thrown. The error message can be obtained via PloyvSdkException.getMessage(), e.g., [Error returned from Polyv request, request ID: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]

Request Parameter Description

Parameter Name Required Type Description
categoryId true String Category ID. Only first-level category properties can be set [Corresponds to API field cataid]
isSettings false String Whether to enable category settings. Y: Enable, N: Disable. Default value is Y: Enable
keepSource false Integer Source file playback. 1 to enable, 0 to disable. When enabled, videos are not transcoded (only effective for newly uploaded videos). Default value is 0: Disable source file playback
encrypt true Integer Video encryption setting switch (only effective for newly uploaded videos). 1: Enable, 0: Disable. Default value is 0: Disable
hlsLevel false String Mobile encryption settings. Valid values: open: Non-encrypted authorization; web: WEB authorization; app: APP authorization; wxa_app: Mini Program authorization. Default value is open: Non-encrypted authorization [Corresponds to API field hlslevel]
isEdu false Integer Video optimization. 1 to enable, 0 to disable (only effective for newly uploaded videos). Default value is 0: Disable
encodeAAC false Integer Generate audio file. 1 to enable, 0 to disable (this feature is only available to authorized users and only effective for newly uploaded videos). Default value is 0: Do not generate [Corresponds to API field encode_aac]

Response Object Description

true indicates modification success, false indicates modification failure.




6. Move Video Category

Description

通过分类id移动视频分类
接口地址(仅做说明使用):https://api.polyv.net/v2/cata/%s/change

Call Constraints

  1. API calls are rate-limited. Click for details. For common call exceptions, click here.

Unit Test

    @Test
    public void testMoveCategory() throws IOException, NoSuchAlgorithmException {
        VodMoveCategoryRequest vodMoveCategoryRequest = new VodMoveCategoryRequest();
        Boolean vodMoveCategoryResponse = null;
        try {
            vodMoveCategoryRequest.setCategoryId("1615536384688")
                    .setDestCategoryId("1");
            vodMoveCategoryResponse = new VodCategoryServiceImpl().moveCategory(vodMoveCategoryRequest);
            Assert.assertTrue(vodMoveCategoryResponse);
            if (vodMoveCategoryResponse) {
                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

  1. On a successful request, a Boolean object is returned. The B-end processes business logic based on this object.
  2. If request parameter validation fails, a PloyvSdkException is thrown. The error message can be obtained via PloyvSdkException.getMessage(), e.g., [Validation failed for input parameter [xxx.chat.VodxxxRequest] object, failed fields: [pic cannot be empty / msg cannot be empty]].
  3. If the server encounters an exception, a PloyvSdkException is thrown. The error message can be obtained via PloyvSdkException.getMessage(), e.g., [Error returned from Polyv request, request ID: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]

Request Parameter Description

Parameter Name Required Type Description
categoryId true String The category directory ID to be moved. (id=1 indicates the default category) [Corresponds to API field cataid]
destCategoryId true String The destination category directory ID. (id=1 indicates the default category) [Corresponds to API field destCataid]

Response Object Description

true indicates modification success, false indicates modification failure.




7. Delete Category

Description

通过分类id删除分类
接口地址(仅做说明使用):https://api.polyv.net/v2/video/%s/deleteCata

Call Constraints

  1. API calls are rate-limited. Click for details. For common call exceptions, click here.

Unit Test

    @Test
    public void testDeleteCategory() throws IOException, NoSuchAlgorithmException {
        VodDeleteCategoryRequest vodDeleteCategoryRequest = new VodDeleteCategoryRequest();
        Boolean vodDeleteCategoryResponse = null;
        try {
            //准备测试数据
            String categoryID = super.createCategoryOther();
            vodDeleteCategoryRequest.setCategoryId(categoryID);
            vodDeleteCategoryResponse = new VodCategoryServiceImpl().deleteCategory(vodDeleteCategoryRequest);
            Assert.assertTrue(vodDeleteCategoryResponse);
            if (vodDeleteCategoryResponse) {
                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

  1. On a successful request, a Boolean object is returned. The B-end processes business logic based on this object.
  2. If request parameter validation fails, a PloyvSdkException is thrown. The error message can be obtained via PloyvSdkException.getMessage(), e.g., [Validation failed for input parameter [xxx.chat.VodxxxRequest] object, failed fields: [pic cannot be empty / msg cannot be empty]].
  3. If the server encounters an exception, a PloyvSdkException is thrown. The error message can be obtained via PloyvSdkException.getMessage(), e.g., [Error returned from Polyv request, request ID: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]

Request Parameter Description

Parameter Name Required Type Description
categoryId true String Video category ID [Corresponds to API field cataid]

Response Object Description

true indicates deletion success, false indicates deletion failure.

联系客服,在线咨询