全部产品

媒体审核

本篇文档提供了Java SDK媒体审核模块相关功能的API调用示例。包含提交智能审核作业、获取智能审核结果、查询智能审核作业、人工审核等。

初始化客户端

使用前请先初始化客户端,请参见初始化

提交智能审核作业

调用SubmitAIMediaAuditJob接口,完成提交智能审核作业功能。

接口参数和返回字段请参见SubmitAIMediaAuditJob。调用示例如下:

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

/**
 * 提交智能审核作业
 */
public static SubmitAIMediaAuditJobResponse submitAIMediaAuditJob(DefaultAcsClient client) throws Exception {
        SubmitAIMediaAuditJobRequest request = new SubmitAIMediaAuditJobRequest();
        // 设置视频ID
        request.setMediaId("dc063078c1d845139e2a5bd8ff****");

        // 返回结果
        return client.getAcsResponse(request);
} 

/**
 * 以下为调用示例
 * @param args
 */
public static void main(String[] args) throws Exception {
        // 初始化客户端
        DefaultAcsClient client = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");

        try {
            // 获取执行结果
            SubmitAIMediaAuditJobResponse response = submitAIMediaAuditJob(client);

            // 打印请求ID
            System.out.println("ResquestId:" + response.getRequestId());
            // 打印视频ID
            System.out.println("MediaId:" + response.getMediaId());
            // 打印作业ID
            System.out.println("JobId:" + response.getJobId());
        } catch (Exception e) {
            System.out.println("ErrorMessage:" + e.getLocalizedMessage());
        }
}

查询智能审核作业

调用GetAIMediaAuditJob接口,完成查询智能审核作业功能。

接口参数和返回字段请参见GetAIMediaAuditJob。调用示例如下:

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

/**
 * 查询智能审核作业
 */
public static GetAIMediaAuditJobResponse getAIMediaAuditJob(DefaultAcsClient client) throws Exception {
        GetAIMediaAuditJobRequest request = new GetAIMediaAuditJobRequest();
        // 设置作业ID
        request.setJobId("7dc69b893c8b4f13b47aae8de0df****");

        // 返回结果
        return client.getAcsResponse(request);
}

/**
 * 以下为调用示例
 * @param args
 */
public static void main(String[] args) throws Exception {
        // 初始化客户端
        DefaultAcsClient client = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");

        try {
            // 获取执行结果
            GetAIMediaAuditJobResponse response = getAIMediaAuditJob(client);

            // 打印请求ID
            System.out.println("ResquestId:" + response.getRequestId());

            // 打印结果信息
            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());
        }
}

获取智能审核结果摘要

调用GetMediaAuditResult接口,完成获取智能审核结果摘要功能。

接口参数和返回字段请参见GetMediaAuditResult。调用示例如下:

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

/**
 * 获取智能审核结果摘要
 */
public static GetMediaAuditResultResponse getMediaAuditResult(DefaultAcsClient client) throws Exception {
        GetMediaAuditResultRequest request = new GetMediaAuditResultRequest();
        // 设置视频ID
        request.setMediaId("dc063078c1d845139e2a5bd8f58****");

        // 返回结果
        return client.getAcsResponse(request);
}

/**
 * 以下为调用示例
 * @param args
 */
// 调用示例
    public static void main(String[] args) throws Exception {
        // 初始化客户端
        DefaultAcsClient client = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");

        try {
            // 获取执行结果
            GetMediaAuditResultResponse response = getMediaAuditResult(client);

            // 打印请求ID
            System.out.println("ResquestId:" + response.getRequestId());

            // 打印作业结果信息
            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());
        }
}

获取智能审核结果详情

调用GetMediaAuditResultDetail接口,完成获取智能审核结果详情功能。

接口参数和返回字段请参见GetMediaAuditResultDetail。调用示例如下:

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

/**
 * 获取智能审核结果详情
 */
public static GetMediaAuditResultDetailResponse getMediaAuditResultDetail(DefaultAcsClient client) throws Exception {
        GetMediaAuditResultDetailRequest request = new GetMediaAuditResultDetailRequest();
        // 设置视频ID
        request.setMediaId("dc063078c1d845139e2a5bd8f69****");
        // 设置翻页页数
        request.setPageNo(1);

        // 返回结果
        return client.getAcsResponse(request);
}

/**
 * 以下为调用示例
 * @param args
 */
public static void main(String[] args) throws Exception {
        // 初始化客户端
        DefaultAcsClient client = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");

        try {
            // 获取执行结果
            GetMediaAuditResultDetailResponse response = getMediaAuditResultDetail(client);

            // 打印请求ID
            System.out.println("ResquestId:" + response.getRequestId());

            // 打印结果信息
            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());
        }
}

获取智能审核结果时间线

调用GetMediaAuditResultTimeline接口,完成获取智能审核结果时间线功能。

接口参数和返回字段请参见GetMediaAuditResultTimeline。调用示例如下:

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

/**
 * 获取智能审核结果时间线
 */
public static GetMediaAuditResultTimelineResponse getMediaAuditResultTimeline(DefaultAcsClient client) throws Exception {
        GetMediaAuditResultTimelineRequest request = new GetMediaAuditResultTimelineRequest();
        // 设置视频ID
        request.setMediaId("dc063078c1d845139e2a5bd8f55****");

        // 返回结果
        return client.getAcsResponse(request);
}

/**
 * 以下为调用示例
 * @param args
 */
public static void main(String[] args) throws Exception {
        // 初始化客户端
        DefaultAcsClient client = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");

        try {
            // 获取执行结果
            GetMediaAuditResultTimelineResponse response = getMediaAuditResultTimeline(client);

            // 打印请求ID
            System.out.println("ResquestId:" + response.getRequestId());

            // 打印结果信息
            System.out.println(response.getMediaAuditResultTimeline().getTerrorism());
            System.out.println(response.getMediaAuditResultTimeline().getPorn());
        } catch (Exception e) {
            System.out.println("ErrorMessage:" + e.getLocalizedMessage());
        }
}

人工审核

调用CreateAuditRequest接口,完成人工审核 功能。

接口参数和返回字段请参见CreateAuditRequest。调用示例如下:

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

/**
 * 构建审核内容
 */
public static String buildAuditContent() throws Exception {
        List<JSONObject> auditContents = new ArrayList<>();

        JSONObject auditContent = new JSONObject();
        auditContent.put("VideoId", "3ebc10160bda481ca9b6858a0b58****"); // 视频ID
        auditContent.put("Status", "Blocked"); // 审核状态
        auditContent.put("Reason", "含有淫秽色情内容"); // 若审核状态为屏蔽时,需给出屏蔽的理由,最长支持128字节
        auditContents.add(auditContent);

        return auditContents.toString();
}

/**
 * 人工审核
 */
public static CreateAuditResponse createAudit(DefaultAcsClient client) throws Exception {
        CreateAuditRequest request = new CreateAuditRequest();
        // 设置审核内容
        request.setAuditContent(buildAuditContent());

        // 返回结果
        return client.getAcsResponse(request);
}

/**
 * 以下为调用示例
 * @param args
 */
public static void main(String[] args) throws Exception {
    DefaultAcsClient client = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");

    try {
        // 提交人工审核结果
        CreateAuditResponse response = createAudit(client);
        // 打印请求ID
        System.out.println("ResquestId:" + response.getRequestId());
    } catch (Exception e) {
        System.out.println("ErrorMessage:" + e.getLocalizedMessage());
    }
}

获取人工审核历史

调用GetAuditHistory接口,完成获取人工审核历史功能。

接口参数和返回字段请参见GetAuditHistory。调用示例如下:

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

/**
 * 获取人工审核历史
 */
public static GetAuditHistoryResponse getAuditHistory(DefaultAcsClient client) throws Exception {
        GetAuditHistoryRequest request = new GetAuditHistoryRequest();

        // 视频ID
        request.setVideoId("3ebc10160bda481ca9b6858a0b25****");
        // 页号
        request.setPageNo(1L);
        // 每页数量
        request.setPageSize(10L);

        // 返回结果
        return client.getAcsResponse(request);
}

/**
 * 以下为调用示例
 * @param args
 */
public static void main(String[] args) throws Exception {
    DefaultAcsClient client = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");

    try {
        // 获取人工审核历史
        GetAuditHistoryResponse response = getAuditHistory(client);

        // 打印请求ID
        System.out.println("ResquestId:" + response.getRequestId());
        // 打印审核历史记录总条数
        System.out.println("Total:" + response.getTotal());
        // 打印本次审核结果
        System.out.println("Status:" + response.getStatus());
        // 打印审核历史记录列表
        System.out.println("Histories:" + response.getHistories().toString());
    } catch (Exception e) {
        System.out.println("ErrorMessage:" + e.getLocalizedMessage());
    }
}

设置审核安全IP

调用SetAuditSecurityIp接口,完成设置审核安全IP功能。

接口参数和返回字段请参见SetAuditSecurityIp。调用示例如下:

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

/**
 * 设置审核安全IP
 */
public static SetAuditSecurityIpResponse setAuditSecurityIp(DefaultAcsClient client) throws Exception {
        SetAuditSecurityIpRequest request = new SetAuditSecurityIpRequest();

        // 审核安全组名称,默认为Default
        request.setSecurityGroupName("MyGroupName");
        // 操作方式,默认值Append(追加IP白名单)
        request.setOperateMode("Cover");
        // 审核安全IP列表
        request.setIps("10.23.12.20,10.23.12.21,10.23.12.22");

        // 返回结果
        return client.getAcsResponse(request);
}

/**
 * 以下为调用示例
 * @param args
 */
public static void main(String[] args) throws Exception {
    DefaultAcsClient client = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");

    try {
        // 设置审核安全IP
        SetAuditSecurityIpResponse response = setAuditSecurityIp(client);

        // 打印请求ID
        System.out.println("ResquestId:" + response.getRequestId());
    } catch (Exception e) {
        System.out.println("ErrorMessage:" + e.getLocalizedMessage());
    }
}

获取审核安全IP列表

调用ListAuditSecurityIp接口,完成获取审核安全IP列表功能。

接口参数和返回字段请参见ListAuditSecurityIp。调用示例如下:

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

/**
 * 获取审核安全IP列表
 */
public static ListAuditSecurityIpResponse listAuditSecurityIp(DefaultAcsClient client) throws Exception {
        ListAuditSecurityIpRequest request = new ListAuditSecurityIpRequest();

        // 审核安全组名称
        request.setSecurityGroupName("MyGroupName");

        // 返回结果
        return client.getAcsResponse(request);
}


/**
 * 以下为调用示例
 * @param args
 */
public static void main(String[] args) throws Exception {
    DefaultAcsClient client = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");

    try {
        // 获取审核安全IP列表
        ListAuditSecurityIpResponse response = listAuditSecurityIp(client);

        // 打印请求ID
        System.out.println("ResquestId:" + response.getRequestId());
        // 打印审核安全IP详情
        System.out.println("SecurityIpList:" + response.getSecurityIpList().toString());
    } catch (Exception e) {
        System.out.println("ErrorMessage:" + e.getLocalizedMessage());
    }
}