All Products
Search
Document Center

Media content moderation

Last Updated: Jul 11, 2019

Initialize a client

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

Submit an automated review job

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

import com.aliyuncs.vod.model.v20170321.SubmitAIMediaAuditJobRequest;
import com.aliyuncs.vod.model.v20170321.SubmitAIMediaAuditJobResponse;

/**
 * Method for submitting an automated review job
 */
public static SubmitAIMediaAuditJobResponse submitAIMediaAuditJob(DefaultAcsClient client) throws Exception {
        SubmitAIMediaAuditJobRequest request = new SubmitAIMediaAuditJobRequest();
        // Sets the video ID.
        request.setMediaId("dc063078c1d845139e2a5bd8ffxxxxxx");

        // Obtains a response.
        return client.getAcsResponse(request);
} 

/**
 * Call example
 * @param args
 */
public static void main(String[] args) throws Exception {
        // Initializes the client.
        DefaultAcsClient client = initVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");

        try {
            // Obtains a response.
            SubmitAIMediaAuditJobResponse response = submitAIMediaAuditJob(client);

            // The GUID generated by Alibaba Cloud for the request.
            System.out.println("RequestId:" + response.getRequestId());
            // The video ID.
            System.out.println("MediaId:" + response.getMediaId());
            // The job ID.
            System.out.println("JobId:" + response.getJobId());
        } catch (Exception e) {
            System.out.println("ErrorMessage:" + e.getLocalizedMessage());
        }
}

Query an automated review job

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

import com.aliyuncs.vod.model.v20170321.GetAIMediaAuditJobRequest;
import com.aliyuncs.vod.model.v20170321.GetAIMediaAuditJobResponse;

/**
 * Method for querying an automated review job
 */
public static GetAIMediaAuditJobResponse getAIMediaAuditJob(DefaultAcsClient client) throws Exception {
        GetAIMediaAuditJobRequest request = new GetAIMediaAuditJobRequest();
        // Sets the job ID.
        request.setJobId("7dc69b893c8b4f13b47aae8de0xxxxxx");

        // Obtains a response.
        return client.getAcsResponse(request);
}

/**
 * Call example
 * @param args
 */
public static void main(String[] args) throws Exception {
        // Initializes the client.
        DefaultAcsClient client = initVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");

        try {
            // Obtains a response.
            GetAIMediaAuditJobResponse response = getAIMediaAuditJob(client);

            // The GUID generated by Alibaba Cloud for the request.
            System.out.println("RequestId:" + response.getRequestId());

            // The job information.
            System.out.println("MediaId:" + response.getMediaAuditJob().getMediaId());
            System.out.println("JobId:" + response.getMediaAuditJob().getJobId());
            System.out.println("Type:" + response.getMediaAuditJob().getType());
            System.out.println("Status:" + response.getMediaAuditJob().getStatus());
            System.out.println("Code:" + response.getMediaAuditJob().getCode());
            System.out.println("Message:" + response.getMediaAuditJob().getMessage());
            System.out.println("Data AbnormalModules:" + response.getMediaAuditJob().getData().getAbnormalModules());
            System.out.println("Data Label:" + response.getMediaAuditJob().getData().getLabel());
            System.out.println("Data Suggestion:" + response.getMediaAuditJob().getData().getSuggestion());
        } catch (Exception e) {
            System.out.println("ErrorMessage:" + e.getLocalizedMessage());
        }
}

Obtain the summary of the automated review result

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

import com.aliyuncs.vod.model.v20170321.GetMediaAuditResultRequest;
import com.aliyuncs.vod.model.v20170321.GetMediaAuditResultResponse;

/**
 * Method for obtaining the summary of the automated review result
 */
public static GetMediaAuditResultResponse getMediaAuditResult(DefaultAcsClient client) throws Exception {
        GetMediaAuditResultRequest request = new GetMediaAuditResultRequest();
        // Sets the video ID.
        request.setMediaId("dc063078c1d845139e2a5bd8fxxxxxx");

        // Obtains a response.
        return client.getAcsResponse(request);
}

/**
 * Call example
 * @param args
 */
// Call example
    public static void main(String[] args) throws Exception {
        // Initializes the client.
        DefaultAcsClient client = initVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");

        try {
            // Obtains a response.
            GetMediaAuditResultResponse response = getMediaAuditResult(client);

            // The GUID generated by Alibaba Cloud for the request.
            System.out.println("RequestId:" + response.getRequestId());

            // The review result information.
            System.out.println("Data AbnormalModules:" + response.getMediaAuditResult().getAbnormalModules());
            System.out.println("Data Label:" + response.getMediaAuditResult().getLabel());
            System.out.println("Data Suggestion:" + response.getMediaAuditResult().getSuggestion());
        } catch (Exception e) {
            System.out.println("ErrorMessage:" + e.getLocalizedMessage());
        }
}

Obtain the details about the automated review result

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

import com.aliyuncs.vod.model.v20170321.GetMediaAuditResultDetailRequest;
import com.aliyuncs.vod.model.v20170321.GetMediaAuditResultDetailResponse;

/**
 * Method for obtaining the details about the automated review result
 */
public static GetMediaAuditResultDetailResponse getMediaAuditResultDetail(DefaultAcsClient client) throws Exception {
        GetMediaAuditResultDetailRequest request = new GetMediaAuditResultDetailRequest();
        // Sets the video ID.
        request.setMediaId("dc063078c1d845139e2a5bd8fxxxxxx");
        // Sets the page number.
        request.setPageNo(1);

        // Obtains a response.
        return client.getAcsResponse(request);
}

/**
 * Call example
 * @param args
 */
public static void main(String[] args) throws Exception {
        // Initializes the client.
        DefaultAcsClient client = initVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");

        try {
            // Obtains a response.
            GetMediaAuditResultDetailResponse response = getMediaAuditResultDetail(client);

            // The GUID generated by Alibaba Cloud for the request.
            System.out.println("RequestId:" + response.getRequestId());

            // The review result information.
            System.out.println("Data Total:" + response.getMediaAuditResultDetail().getTotal());
            System.out.println("Data List Size:" + response.getMediaAuditResultDetail().getList().size());
        } catch (Exception e) {
            System.out.println("ErrorMessage:" + e.getLocalizedMessage());
        }
}

Obtain the timeline of the automated review result

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

import com.aliyuncs.vod.model.v20170321.GetMediaAuditResultTimelineRequest;
import com.aliyuncs.vod.model.v20170321.GetMediaAuditResultTimelineResponse;

/**
 * Method for obtaining the timeline of the automated review result
 */
public static GetMediaAuditResultTimelineResponse getMediaAuditResultTimeline(DefaultAcsClient client) throws Exception {
        GetMediaAuditResultTimelineRequest request = new GetMediaAuditResultTimelineRequest();
        // Sets the video ID.
        request.setMediaId("dc063078c1d845139e2a5bd8fxxxxxx");

        // Obtains a response.
        return client.getAcsResponse(request);
}

/**
 * Call example
 * @param args
 */
public static void main(String[] args) throws Exception {
        // Initializes the client.
        DefaultAcsClient client = initVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");

        try {
            // Obtains a response.
            GetMediaAuditResultTimelineResponse response = getMediaAuditResultTimeline(client);

            // The GUID generated by Alibaba Cloud for the request.
            System.out.println("RequestId:" + response.getRequestId());

            // The review result information.
            System.out.println(response.getMediaAuditResultTimeline().getTerrorism());
            System.out.println(response.getMediaAuditResultTimeline().getPorn());
        } catch (Exception e) {
            System.out.println("ErrorMessage:" + e.getLocalizedMessage());
        }
}

Start a manual review

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

import com.aliyuncs.vod.model.v20170321.CreateAuditRequest;
import com.aliyuncs.vod.model.v20170321.CreateAuditResponse;
import com.alibaba.fastjson.JSONObject;

/**
 * Method for constructing the manual review content
 */
public static String buildAuditContent() throws Exception {
        List<JSONObject> auditContents = new ArrayList<>(); 

        JSONObject auditContent = new JSONObject();
        auditContent.put("VideoId", "3ebc10160bda481ca9b6858a0bxxxxxx"); // Sets the video ID.
        auditContent.put("Status", "Blocked"); // Sets the review status.
        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.
        auditContents.add(auditContent);

        return auditContents.toString();
}

/**
 * Method for starting a manual review
 */
public static CreateAuditResponse createAudit(DefaultAcsClient client) throws Exception {
        CreateAuditRequest request = new CreateAuditRequest();
        // Sets the manual review content.
        request.setAuditContent(buildAuditContent());

        // Obtains a response.
        return client.getAcsResponse(request);
}

/**
 * Call example
 * @param args
 */
public static void main(String[] args) throws Exception {
    DefaultAcsClient client = initVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");

    try {
        // Starts a manual review and obtains a response.
        CreateAuditResponse response = createAudit(client);
        // The GUID generated by Alibaba Cloud for the request.
        System.out.println("RequestId:" + response.getRequestId());
    } catch (Exception e) {
        System.out.println("ErrorMessage:" + e.getLocalizedMessage());
    }
}

Obtain the manual review history

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

import com.aliyuncs.vod.model.v20170321.GetAuditHistoryRequest;
import com.aliyuncs.vod.model.v20170321.GetAuditHistoryResponse;

/**
 * Method for obtaining the manual review history
 */
public static GetAuditHistoryResponse getAuditHistory(DefaultAcsClient client) throws Exception {
        GetAuditHistoryRequest request = new GetAuditHistoryRequest();

        // Sets the video ID.
        request.setVideoId("3ebc10160bda481ca9b6858a0bxxxxxx");
        // Sets the page number.
        request.setPageNo(1L);
        // Sets the number of data records per page.
        request.setPageSize(10L);

        // Obtains a response.
        return client.getAcsResponse(request);
}

/**
 * Call example
 * @param args
 */
public static void main(String[] args) throws Exception {
    DefaultAcsClient client = initVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");

    try {
        // Obtains the manual review history.
        GetAuditHistoryResponse response = getAuditHistory(client);

        // The GUID generated by Alibaba Cloud for the request.
        System.out.println("RequestId:" + response.getRequestId());
        // The total number of records in the manual review history.
        System.out.println("Total:" + response.getTotal());
        // The latest manual review result.
        System.out.println("Status:" + response.getStatus());
        // The list of records in the manual review history.
        System.out.println("Histories:" + response.getHistories().toString());
    } catch (Exception e) {
        System.out.println("ErrorMessage:" + e.getLocalizedMessage());
    }
}

Add IP addresses to review security groups

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

import com.aliyuncs.vod.model.v20170321.SetAuditSecurityIpRequest;
import com.aliyuncs.vod.model.v20170321.SetAuditSecurityIpResponse;

/**
 * Method for adding IP addresses to review security groups
 */
public static SetAuditSecurityIpResponse setAuditSecurityIp(DefaultAcsClient client) throws Exception {
        SetAuditSecurityIpRequest request = new SetAuditSecurityIpRequest();

        // Sets the name of each review security group. Default value: Default.
        request.setSecurityGroupName("MyGroupName");
        // Sets the write mode. The default value Append indicates that new IP addresses are appended to the whitelist.
        request.setOperateMode("Cover");
        // Sets the whitelist of IP addresses in each review security group.
        request.setIps("10.23.12.20,10.23.12.21,10.23.12.22");

        // Obtains a response.
        return client.getAcsResponse(request);
}

/**
 * Call example
 * @param args
 */
public static void main(String[] args) throws Exception {
    DefaultAcsClient client = initVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");

    try {
        // Adds IP addresses to review security groups and obtains a response.
        SetAuditSecurityIpResponse response = setAuditSecurityIp(client);

        // The GUID generated by Alibaba Cloud for the request.
        System.out.println("RequestId:" + response.getRequestId());
    } catch (Exception e) {
        System.out.println("ErrorMessage:" + e.getLocalizedMessage());
    }
}

Obtain a whitelist of IP addresses in review security groups

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

import com.aliyuncs.vod.model.v20170321.ListAuditSecurityIpRequest;
import com.aliyuncs.vod.model.v20170321.ListAuditSecurityIpResponse;

/**
 * Method for obtaining a whitelist of IP addresses in review security groups
 */
public static ListAuditSecurityIpResponse listAuditSecurityIp(DefaultAcsClient client) throws Exception {
        ListAuditSecurityIpRequest request = new ListAuditSecurityIpRequest();

        // Sets the name of each review security group.
        request.setSecurityGroupName("MyGroupName");

        // Obtains a response.
        return client.getAcsResponse(request);
}


/**
 * Call example
 * @param args
 */
public static void main(String[] args) throws Exception {
    DefaultAcsClient client = initVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");

    try {
        // Obtains a whitelist of IP addresses in review security groups.
        ListAuditSecurityIpResponse response = listAuditSecurityIp(client);

        // The GUID generated by Alibaba Cloud for the request.
        System.out.println("RequestId:" + response.getRequestId());
        // The whitelist of IP addresses in review security groups.
        System.out.println("SecurityIpList:" + response.getSecurityIpList().toString());
    } catch (Exception e) {
        System.out.println("ErrorMessage:" + e.getLocalizedMessage());
    }
}