All Products
Search
Document Center

Media content moderation

Last Updated: May 27, 2020

Initialize a client

Initialize a client before using the SDK. For more information, see initVodClient.

Submit an automated review job

  1. import com.aliyuncs.vod.model.v20170321.SubmitAIMediaAuditJobRequest;
  2. import com.aliyuncs.vod.model.v20170321.SubmitAIMediaAuditJobResponse;
  3. /**
  4. * Method for submitting an automated review job
  5. */
  6. public static SubmitAIMediaAuditJobResponse submitAIMediaAuditJob(DefaultAcsClient client) throws Exception {
  7. SubmitAIMediaAuditJobRequest request = new SubmitAIMediaAuditJobRequest();
  8. // Sets the video ID.
  9. request.setMediaId("dc063078c1d845139e2a5bd8ffxxxxxx");
  10. // Obtains a response.
  11. return client.getAcsResponse(request);
  12. }
  13. /**
  14. * Call example
  15. * @param args
  16. */
  17. public static void main(String[] args) throws Exception {
  18. // Initializes the client.
  19. DefaultAcsClient client = initVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
  20. try {
  21. // Obtains a response.
  22. SubmitAIMediaAuditJobResponse response = submitAIMediaAuditJob(client);
  23. // The GUID generated by Alibaba Cloud for the request.
  24. System.out.println("RequestId:" + response.getRequestId());
  25. // The video ID.
  26. System.out.println("MediaId:" + response.getMediaId());
  27. // The job ID.
  28. System.out.println("JobId:" + response.getJobId());
  29. } catch (Exception e) {
  30. System.out.println("ErrorMessage:" + e.getLocalizedMessage());
  31. }
  32. }

Query an automated review job

  1. import com.aliyuncs.vod.model.v20170321.GetAIMediaAuditJobRequest;
  2. import com.aliyuncs.vod.model.v20170321.GetAIMediaAuditJobResponse;
  3. /**
  4. * Method for querying an automated review job
  5. */
  6. public static GetAIMediaAuditJobResponse getAIMediaAuditJob(DefaultAcsClient client) throws Exception {
  7. GetAIMediaAuditJobRequest request = new GetAIMediaAuditJobRequest();
  8. // Sets the job ID.
  9. request.setJobId("7dc69b893c8b4f13b47aae8de0xxxxxx");
  10. // Obtains a response.
  11. return client.getAcsResponse(request);
  12. }
  13. /**
  14. * Call example
  15. * @param args
  16. */
  17. public static void main(String[] args) throws Exception {
  18. // Initializes the client.
  19. DefaultAcsClient client = initVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
  20. try {
  21. // Obtains a response.
  22. GetAIMediaAuditJobResponse response = getAIMediaAuditJob(client);
  23. // The GUID generated by Alibaba Cloud for the request.
  24. System.out.println("RequestId:" + response.getRequestId());
  25. // The job information.
  26. System.out.println("MediaId:" + response.getMediaAuditJob().getMediaId());
  27. System.out.println("JobId:" + response.getMediaAuditJob().getJobId());
  28. System.out.println("Type:" + response.getMediaAuditJob().getType());
  29. System.out.println("Status:" + response.getMediaAuditJob().getStatus());
  30. System.out.println("Code:" + response.getMediaAuditJob().getCode());
  31. System.out.println("Message:" + response.getMediaAuditJob().getMessage());
  32. System.out.println("Data AbnormalModules:" + response.getMediaAuditJob().getData().getAbnormalModules());
  33. System.out.println("Data Label:" + response.getMediaAuditJob().getData().getLabel());
  34. System.out.println("Data Suggestion:" + response.getMediaAuditJob().getData().getSuggestion());
  35. } catch (Exception e) {
  36. System.out.println("ErrorMessage:" + e.getLocalizedMessage());
  37. }
  38. }

Obtain the summary of the automated review result

  1. import com.aliyuncs.vod.model.v20170321.GetMediaAuditResultRequest;
  2. import com.aliyuncs.vod.model.v20170321.GetMediaAuditResultResponse;
  3. /**
  4. * Method for obtaining the summary of the automated review result
  5. */
  6. public static GetMediaAuditResultResponse getMediaAuditResult(DefaultAcsClient client) throws Exception {
  7. GetMediaAuditResultRequest request = new GetMediaAuditResultRequest();
  8. // Sets the video ID.
  9. request.setMediaId("dc063078c1d845139e2a5bd8fxxxxxx");
  10. // Obtains a response.
  11. return client.getAcsResponse(request);
  12. }
  13. /**
  14. * Call example
  15. * @param args
  16. */
  17. // Call example
  18. public static void main(String[] args) throws Exception {
  19. // Initializes the client.
  20. DefaultAcsClient client = initVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
  21. try {
  22. // Obtains a response.
  23. GetMediaAuditResultResponse response = getMediaAuditResult(client);
  24. // The GUID generated by Alibaba Cloud for the request.
  25. System.out.println("RequestId:" + response.getRequestId());
  26. // The review result information.
  27. System.out.println("Data AbnormalModules:" + response.getMediaAuditResult().getAbnormalModules());
  28. System.out.println("Data Label:" + response.getMediaAuditResult().getLabel());
  29. System.out.println("Data Suggestion:" + response.getMediaAuditResult().getSuggestion());
  30. } catch (Exception e) {
  31. System.out.println("ErrorMessage:" + e.getLocalizedMessage());
  32. }
  33. }

Obtain the details about the automated review result

  1. import com.aliyuncs.vod.model.v20170321.GetMediaAuditResultDetailRequest;
  2. import com.aliyuncs.vod.model.v20170321.GetMediaAuditResultDetailResponse;
  3. /**
  4. * Method for obtaining the details about the automated review result
  5. */
  6. public static GetMediaAuditResultDetailResponse getMediaAuditResultDetail(DefaultAcsClient client) throws Exception {
  7. GetMediaAuditResultDetailRequest request = new GetMediaAuditResultDetailRequest();
  8. // Sets the video ID.
  9. request.setMediaId("dc063078c1d845139e2a5bd8fxxxxxx");
  10. // Sets the page number.
  11. request.setPageNo(1);
  12. // Obtains a response.
  13. return client.getAcsResponse(request);
  14. }
  15. /**
  16. * Call example
  17. * @param args
  18. */
  19. public static void main(String[] args) throws Exception {
  20. // Initializes the client.
  21. DefaultAcsClient client = initVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
  22. try {
  23. // Obtains a response.
  24. GetMediaAuditResultDetailResponse response = getMediaAuditResultDetail(client);
  25. // The GUID generated by Alibaba Cloud for the request.
  26. System.out.println("RequestId:" + response.getRequestId());
  27. // The review result information.
  28. System.out.println("Data Total:" + response.getMediaAuditResultDetail().getTotal());
  29. System.out.println("Data List Size:" + response.getMediaAuditResultDetail().getList().size());
  30. } catch (Exception e) {
  31. System.out.println("ErrorMessage:" + e.getLocalizedMessage());
  32. }
  33. }

Obtain the timeline of the automated review result

  1. import com.aliyuncs.vod.model.v20170321.GetMediaAuditResultTimelineRequest;
  2. import com.aliyuncs.vod.model.v20170321.GetMediaAuditResultTimelineResponse;
  3. /**
  4. * Method for obtaining the timeline of the automated review result
  5. */
  6. public static GetMediaAuditResultTimelineResponse getMediaAuditResultTimeline(DefaultAcsClient client) throws Exception {
  7. GetMediaAuditResultTimelineRequest request = new GetMediaAuditResultTimelineRequest();
  8. // Sets the video ID.
  9. request.setMediaId("dc063078c1d845139e2a5bd8fxxxxxx");
  10. // Obtains a response.
  11. return client.getAcsResponse(request);
  12. }
  13. /**
  14. * Call example
  15. * @param args
  16. */
  17. public static void main(String[] args) throws Exception {
  18. // Initializes the client.
  19. DefaultAcsClient client = initVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
  20. try {
  21. // Obtains a response.
  22. GetMediaAuditResultTimelineResponse response = getMediaAuditResultTimeline(client);
  23. // The GUID generated by Alibaba Cloud for the request.
  24. System.out.println("RequestId:" + response.getRequestId());
  25. // The review result information.
  26. System.out.println(response.getMediaAuditResultTimeline().getTerrorism());
  27. System.out.println(response.getMediaAuditResultTimeline().getPorn());
  28. } catch (Exception e) {
  29. System.out.println("ErrorMessage:" + e.getLocalizedMessage());
  30. }
  31. }

Start a manual review

For more information about the request and response parameters, see CreateAudit.

  1. import com.aliyuncs.vod.model.v20170321.CreateAuditRequest;
  2. import com.aliyuncs.vod.model.v20170321.CreateAuditResponse;
  3. import com.alibaba.fastjson.JSONObject;
  4. /**
  5. * Method for constructing the manual review content
  6. */
  7. public static String buildAuditContent() throws Exception {
  8. List<JSONObject> auditContents = new ArrayList<>();
  9. JSONObject auditContent = new JSONObject();
  10. auditContent.put("VideoId", "3ebc10160bda481ca9b6858a0bxxxxxx"); // Sets the video ID.
  11. auditContent.put("Status", "Blocked"); // Sets the review status.
  12. auditContent.put("Reason", "porn video"); // Specifies the reason for blocking the video if the Status parameter is set to Blocked. Length constraint: maximum length of 128 bytes.
  13. auditContents.add(auditContent);
  14. return auditContents.toString();
  15. }
  16. /**
  17. * Method for starting a manual review
  18. */
  19. public static CreateAuditResponse createAudit(DefaultAcsClient client) throws Exception {
  20. CreateAuditRequest request = new CreateAuditRequest();
  21. // Sets the manual review content.
  22. request.setAuditContent(buildAuditContent());
  23. // Obtains a response.
  24. return client.getAcsResponse(request);
  25. }
  26. /**
  27. * Call example
  28. * @param args
  29. */
  30. public static void main(String[] args) throws Exception {
  31. DefaultAcsClient client = initVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
  32. try {
  33. // Starts a manual review and obtains a response.
  34. CreateAuditResponse response = createAudit(client);
  35. // The GUID generated by Alibaba Cloud for the request.
  36. System.out.println("RequestId:" + response.getRequestId());
  37. } catch (Exception e) {
  38. System.out.println("ErrorMessage:" + e.getLocalizedMessage());
  39. }
  40. }

Obtain the manual review history

For more information about the request and response parameters, see GetAuditHistory.

  1. import com.aliyuncs.vod.model.v20170321.GetAuditHistoryRequest;
  2. import com.aliyuncs.vod.model.v20170321.GetAuditHistoryResponse;
  3. /**
  4. * Method for obtaining the manual review history
  5. */
  6. public static GetAuditHistoryResponse getAuditHistory(DefaultAcsClient client) throws Exception {
  7. GetAuditHistoryRequest request = new GetAuditHistoryRequest();
  8. // Sets the video ID.
  9. request.setVideoId("3ebc10160bda481ca9b6858a0bxxxxxx");
  10. // Sets the page number.
  11. request.setPageNo(1L);
  12. // Sets the number of data records per page.
  13. request.setPageSize(10L);
  14. // Obtains a response.
  15. return client.getAcsResponse(request);
  16. }
  17. /**
  18. * Call example
  19. * @param args
  20. */
  21. public static void main(String[] args) throws Exception {
  22. DefaultAcsClient client = initVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
  23. try {
  24. // Obtains the manual review history.
  25. GetAuditHistoryResponse response = getAuditHistory(client);
  26. // The GUID generated by Alibaba Cloud for the request.
  27. System.out.println("RequestId:" + response.getRequestId());
  28. // The total number of records in the manual review history.
  29. System.out.println("Total:" + response.getTotal());
  30. // The latest manual review result.
  31. System.out.println("Status:" + response.getStatus());
  32. // The list of records in the manual review history.
  33. System.out.println("Histories:" + response.getHistories().toString());
  34. } catch (Exception e) {
  35. System.out.println("ErrorMessage:" + e.getLocalizedMessage());
  36. }
  37. }

Add IP addresses to review security groups

For more information about the request and response parameters, see SetAuditSecurityIp.

  1. import com.aliyuncs.vod.model.v20170321.SetAuditSecurityIpRequest;
  2. import com.aliyuncs.vod.model.v20170321.SetAuditSecurityIpResponse;
  3. /**
  4. * Method for adding IP addresses to review security groups
  5. */
  6. public static SetAuditSecurityIpResponse setAuditSecurityIp(DefaultAcsClient client) throws Exception {
  7. SetAuditSecurityIpRequest request = new SetAuditSecurityIpRequest();
  8. // Sets the name of each review security group. Default value: Default.
  9. request.setSecurityGroupName("MyGroupName");
  10. // Sets the write mode. The default value Append indicates that new IP addresses are appended to the whitelist.
  11. request.setOperateMode("Cover");
  12. // Sets the whitelist of IP addresses in each review security group.
  13. request.setIps("10.23.12.20,10.23.12.21,10.23.12.22");
  14. // Obtains a response.
  15. return client.getAcsResponse(request);
  16. }
  17. /**
  18. * Call example
  19. * @param args
  20. */
  21. public static void main(String[] args) throws Exception {
  22. DefaultAcsClient client = initVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
  23. try {
  24. // Adds IP addresses to review security groups and obtains a response.
  25. SetAuditSecurityIpResponse response = setAuditSecurityIp(client);
  26. // The GUID generated by Alibaba Cloud for the request.
  27. System.out.println("RequestId:" + response.getRequestId());
  28. } catch (Exception e) {
  29. System.out.println("ErrorMessage:" + e.getLocalizedMessage());
  30. }
  31. }

Obtain a whitelist of IP addresses in review security groups

For more information about the request and response parameters, see ListAuditSecurityIp.

  1. import com.aliyuncs.vod.model.v20170321.ListAuditSecurityIpRequest;
  2. import com.aliyuncs.vod.model.v20170321.ListAuditSecurityIpResponse;
  3. /**
  4. * Method for obtaining a whitelist of IP addresses in review security groups
  5. */
  6. public static ListAuditSecurityIpResponse listAuditSecurityIp(DefaultAcsClient client) throws Exception {
  7. ListAuditSecurityIpRequest request = new ListAuditSecurityIpRequest();
  8. // Sets the name of each review security group.
  9. request.setSecurityGroupName("MyGroupName");
  10. // Obtains a response.
  11. return client.getAcsResponse(request);
  12. }
  13. /**
  14. * Call example
  15. * @param args
  16. */
  17. public static void main(String[] args) throws Exception {
  18. DefaultAcsClient client = initVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
  19. try {
  20. // Obtains a whitelist of IP addresses in review security groups.
  21. ListAuditSecurityIpResponse response = listAuditSecurityIp(client);
  22. // The GUID generated by Alibaba Cloud for the request.
  23. System.out.println("RequestId:" + response.getRequestId());
  24. // The whitelist of IP addresses in review security groups.
  25. System.out.println("SecurityIpList:" + response.getSecurityIpList().toString());
  26. } catch (Exception e) {
  27. System.out.println("ErrorMessage:" + e.getLocalizedMessage());
  28. }
  29. }