全部产品

媒体审核

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

初始化客户端

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

提交智能审核作业

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

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

using System;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.Core.Profile;
using Aliyun.Acs.vod.Model.V20170321;

namespace Aliyun.Acs.vod.Sdk.SubmitAIMediaAuditJob
{
    class MainClass
    {
        /// <summary>
        /// The entry point of the program, where the program control starts and ends.
        /// </summary>
        /// <param name="args">The command-line arguments.</param>
        public static void Main(string[] args)
        {
            try
            {
                // 初始化客户端
                DefaultAcsClient client = InitVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
                // 发起请求,并得到 response
                SubmitAIMediaAuditJobResponse response = SubmitAIMediaAuditJob(client);
                Console.WriteLine("RequestId = " + response.RequestId);
            }
            catch (ServerException e)
            {
                if (e.RequestId != null)
                {
                    Console.WriteLine("RequestId = " + e.RequestId);
                }
                Console.WriteLine("ErrorCode = " + e.ErrorCode);
                Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
            }
            catch (ClientException e)
            {
                if (e.RequestId != null)
                {
                    Console.WriteLine("RequestId = " + e.RequestId);
                }
                Console.WriteLine("ErrorCode = " + e.ErrorCode);
                Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
            }
            catch (Exception e)
            {
                Console.WriteLine("ErrorMessage = " + e.ToString());
            }
        }

        /// <summary>
        /// 提交智能审核作业
        /// </summary>
        /// <param name="client">Client.</param>
        /// <summary>
        /// 提交智能审核作业.
        /// </summary>
        /// <returns>智能审核作业.</returns>
        /// <param name="client">Client.</param>
        public static SubmitAIMediaAuditJobResponse SubmitAIMediaAuditJob(DefaultAcsClient client)
        {
        // 构造请求
        SubmitAIMediaAuditJobRequest request = new SubmitAIMediaAuditJobRequest();
        // 设置视频ID
        request.MediaId = "dc063078c1d845139e2a5bd8ff89****";
        // 返回结果
        return client.GetAcsResponse(request);
        }
    }
}

查询智能审核作业

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

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

using System;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.Core.Profile;
using Aliyun.Acs.vod.Model.V20170321;

namespace Aliyun.Acs.vod.Sdk.GetAIMediaAuditJob
{
    class MainClass
    {
        /// <summary>
        /// The entry point of the program, where the program control starts and ends.
        /// </summary>
        /// <param name="args">The command-line arguments.</param>
        public static void Main(string[] args)
        {
            try
            {
                // 初始化客户端
                DefaultAcsClient client = InitVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
                // 发起请求,并得到 response
                GetAIMediaAuditJobResponse response = GetAIMediaAuditJob(client);
                // 打印请求ID
                Console.WriteLine("RequestId = " + response.RequestId);
                // 打印结果信息
                Console.WriteLine("MediaId = " + response.MediaAuditJob.MediaId);
                Console.WriteLine("JobId = " + response.MediaAuditJob.JobId);
                Console.WriteLine("Type = " + response.MediaAuditJob.Type);
                Console.WriteLine("Status = " + response.MediaAuditJob.Status);
                Console.WriteLine("Code = " + response.MediaAuditJob.Code);
                Console.WriteLine("Message = " + response.MediaAuditJob.Message);
                Console.WriteLine("Data AbnormalModules = " + response.MediaAuditJob.Data.AbnormalModules);
                Console.WriteLine("Data Label = " + response.MediaAuditJob.Data.Label);
                Console.WriteLine("Data Suggestion = " + response.MediaAuditJob.Data.Suggestion);
            }
            catch (ServerException e)
            {
                if (e.RequestId != null)
                {
                    Console.WriteLine("RequestId = " + e.RequestId);
                }
                Console.WriteLine("ErrorCode = " + e.ErrorCode);
                Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
            }
            catch (ClientException e)
            {
                if (e.RequestId != null)
                {
                    Console.WriteLine("RequestId = " + e.RequestId);
                }
                Console.WriteLine("ErrorCode = " + e.ErrorCode);
                Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
            }
            catch (Exception e)
            {
                Console.WriteLine("ErrorMessage = " + e.ToString());
            }
        }

        /// <summary>
        /// 查询智能审核作业.
        /// </summary>
        /// <returns>智能审核作业.</returns>
        /// <param name="client">Client.</param>
        public static GetAIMediaAuditJobResponse GetAIMediaAuditJob(DefaultAcsClient client)
        {
            // 构造请求
            GetAIMediaAuditJobRequest request = new GetAIMediaAuditJobRequest();
            // 设置作业ID
            request.JobId = "7dc69b893c8b4f13b47aae8de059****";
            // 返回结果
            return client.GetAcsResponse(request);

        }
    }
}

获取智能审核结果摘要

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

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

using System;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.Core.Profile;
using Aliyun.Acs.vod.Model.V20170321;

namespace Aliyun.Acs.vod.Sdk.GetMediaAuditResult
{
    class MainClass
    {
        /// <summary>
        /// The entry point of the program, where the program control starts and ends.
        /// </summary>
        /// <param name="args">The command-line arguments.</param>
        public static void Main(string[] args)
        {
            try
            {
                // 初始化客户端
                DefaultAcsClient client = InitVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
                // 发起请求,并得到 response
                GetMediaAuditResultResponse response = GetMediaAuditResult(client);
                // 打印请求ID
                Console.WriteLine("RequestId = " + response.RequestId);
                // 打印结果信息
                Console.WriteLine("Data AbnormalModules = " + response.MediaAuditResult.AbnormalModules);
                Console.WriteLine("Data Label = " + response.MediaAuditResult.Label);
                Console.WriteLine("Data Suggestion = " + response.MediaAuditResult.Suggestion);
            }
            catch (ServerException e)
            {
                if (e.RequestId != null)
                {
                    Console.WriteLine("RequestId = " + e.RequestId);
                }
                Console.WriteLine("ErrorCode = " + e.ErrorCode);
                Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
            }
            catch (ClientException e)
            {
                if (e.RequestId != null)
                {
                    Console.WriteLine("RequestId = " + e.RequestId);
                }
                Console.WriteLine("ErrorCode = " + e.ErrorCode);
                Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
            }
            catch (Exception e)
            {
                Console.WriteLine("ErrorMessage = " + e.ToString());
            }
        }

        /// <summary>
        /// 获取智能审核结果摘要
        /// </summary>
        /// <returns>智能审核结果摘要</returns>
        /// <param name="client">Client.</param>
        public static GetMediaAuditResultResponse GetMediaAuditResult(DefaultAcsClient client)
        {
            // 构造请求
            GetMediaAuditResultRequest request = new GetMediaAuditResultRequest();
            // 设置视频ID
            request.MediaId = "7dc69b893c8b4f13b47aae8de053****";
            // 返回结果
            return client.GetAcsResponse(request);

        }
    }
}

获取智能审核结果详情

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

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

using System;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.Core.Profile;
using Aliyun.Acs.vod.Model.V20170321;

namespace Aliyun.Acs.vod.Sdk.GetMediaAuditResultDetail
{
    class MainClass
    {
        /// <summary>
        /// The entry point of the program, where the program control starts and ends.
        /// </summary>
        /// <param name="args">The command-line arguments.</param>
        public static void Main(string[] args)
        {
            try
            {
                // 初始化客户端
                DefaultAcsClient client = InitVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
                // 发起请求,并得到 response
                GetMediaAuditResultDetailResponse response = GetMediaAuditResultDetail(client);
                // 打印请求ID
                Console.WriteLine("RequestId = " + response.RequestId);
                // 打印结果信息
                Console.WriteLine("Data Total = " + response.MediaAuditResultDetail.Total);
                Console.WriteLine("Data List Size = " + response.MediaAuditResultDetail.List.Count);
            }
            catch (ServerException e)
            {
                if (e.RequestId != null)
                {
                    Console.WriteLine("RequestId = " + e.RequestId);
                }
                Console.WriteLine("ErrorCode = " + e.ErrorCode);
                Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
            }
            catch (ClientException e)
            {
                if (e.RequestId != null)
                {
                    Console.WriteLine("RequestId = " + e.RequestId);
                }
                Console.WriteLine("ErrorCode = " + e.ErrorCode);
                Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
            }
            catch (Exception e)
            {
                Console.WriteLine("ErrorMessage = " + e.ToString());
            }
        }

        /// <summary>
        /// 获取智能审核结果详情
        /// </summary>
        /// <returns>智能审核结果详情</returns>
        /// <param name="client">Client.</param>
        public static GetMediaAuditResultDetailResponse GetMediaAuditResultDetail(DefaultAcsClient client)
        {
            // 构造请求
            GetMediaAuditResultDetailRequest request = new GetMediaAuditResultDetailRequest();
            // 设置视频ID
            request.MediaId = "7dc69b893c8b4f13b47aae8de0565****";
            // 设置翻页页数
            request.PageNo = 1;
            // 返回结果
            return client.GetAcsResponse(request);

        }
    }
}

获取智能审核结果时间线

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

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

using System;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.Core.Profile;
using Aliyun.Acs.vod.Model.V20170321;

namespace Aliyun.Acs.vod.Sdk.GetMediaAuditResultTimeline
{
    class MainClass
    {
        /// <summary>
        /// The entry point of the program, where the program control starts and ends.
        /// </summary>
        /// <param name="args">The command-line arguments.</param>
        public static void Main(string[] args)
        {
            try
            {
                // 初始化客户端
                DefaultAcsClient client = InitVodClient("<Your AccessKeyId>","<Your AccessKeySecret>");
                // 发起请求,并得到 response
                GetMediaAuditResultTimelineResponse response = GetMediaAuditResultTimeline(client);
                // 打印请求ID
                Console.WriteLine("RequestId = " + response.RequestId);
                // 打印结果信息
                Console.WriteLine("Terrorism = " + response.MediaAuditResultTimeline.Terrorism);
                Console.WriteLine("Porn = " + response.MediaAuditResultTimeline.Porn);
            }
            catch (ServerException e)
            {
                if (e.RequestId != null)
                {
                    Console.WriteLine("RequestId = " + e.RequestId);
                }
                Console.WriteLine("ErrorCode = " + e.ErrorCode);
                Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
            }
            catch (ClientException e)
            {
                if (e.RequestId != null)
                {
                    Console.WriteLine("RequestId = " + e.RequestId);
                }
                Console.WriteLine("ErrorCode = " + e.ErrorCode);
                Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
            }
            catch (Exception e)
            {
                Console.WriteLine("ErrorMessage = " + e.ToString());
            }
        }

        /// <summary>
        /// 获取智能审核结果时间线
        /// </summary>
        /// <returns>智能审核结果时间线</returns>
        /// <param name="client">Client.</param>
        public static GetMediaAuditResultTimelineResponse GetMediaAuditResultTimeline(DefaultAcsClient client)
        {
            // 构造请求
            GetMediaAuditResultTimelineRequest request = new GetMediaAuditResultTimelineRequest();
            // 设置视频ID
            request.MediaId = "7dc69b893c8b4f13b47aae8de036****";
            // 返回结果
            return client.GetAcsResponse(request);

        }
    }
}

人工审核

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

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

using System;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.vod.Model.V20170321;
using Newtonsoft.Json.Linq;

namespace Aliyun.Acs.vod.Sdk.CreateAudit
{
    class MainClass
    {
        /// <summary>
        /// The entry point of the program, where the program control starts and ends.
        /// </summary>
        /// <param name="args">The command-line arguments.</param>
        public static void Main(string[] args)
        {
            try
            {
                // 初始化客户端
                DefaultAcsClient client = InitVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
                // 发起请求,并得到 response
                CreateAuditResponse response = CreateAudit(client);
                Console.WriteLine("RequestId = " + response.RequestId);
            }
            catch (ServerException e)
            {
                if (e.RequestId != null)
                {
                    Console.WriteLine("RequestId = " + e.RequestId);
                }
                Console.WriteLine("ErrorCode = " + e.ErrorCode);
                Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
            }
            catch (ClientException e)
            {
                if (e.RequestId != null)
                {
                    Console.WriteLine("RequestId = " + e.RequestId);
                }
                Console.WriteLine("ErrorCode = " + e.ErrorCode);
                Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
            }
            catch (Exception e)
            {
                Console.WriteLine("ErrorMessage = " + e.ToString());
            }
        }

        /// <summary>
        /// Creates the audit.
        /// </summary>
        /// <returns>The audit.</returns>
        /// <param name="client">Client.</param>
        public static CreateAuditResponse CreateAudit(DefaultAcsClient client) 
        {
            CreateAuditRequest request = new CreateAuditRequest();
            // set audit content
            request.AuditContent = BuildAuditContent();

            return client.GetAcsResponse(request);
        }

        /// <summary>
        /// Builds the content of the audit.
        /// </summary>
        /// <returns>The audit content.</returns>
        public static string BuildAuditContent() 
        {
            JArray auditContents = new JArray();
            JObject auditContent = new JObject();
            auditContent.Add("VideoId", "3ebc10160bda481ca9b6858a0b65****");
            auditContent.Add("Status", "Blocked");
            auditContent.Add("Reason", "含有淫秽色情内容");

            return auditContents.ToString();
        }
    }
}

获取人工审核历史

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

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

using System;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.Core.Profile;
using Aliyun.Acs.vod.Model.V20170321;

namespace Aliyun.Acs.vod.Sdk.GetAuditHistory
{
  class MainClass
  {
        /// <summary>
        /// The entry point of the program, where the program control starts and ends.
        /// </summary>
        /// <param name="args">The command-line arguments.</param>
        public static void Main(string[] args)
        {
            try
            {
                // 初始化客户端
                DefaultAcsClient client = InitVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
                // 发起请求,并得到 response
                GetAuditHistoryResponse response = GetAuditHistory(client);
                Console.WriteLine("RequestId = " + response.RequestId);
                // 最新审核结果
                Console.WriteLine("Status = " + response.Status);
                // 审核历史记录数
                Console.WriteLine("Total = " + response.Total);

                if (response.Histories != null && response.Histories.Count > 0)
                {
                    foreach (GetAuditHistoryResponse.GetAuditHistory_History history in response.Histories) {
                        Console.WriteLine("Status = " + history.Status);
                        Console.WriteLine("CreationTime = " + history.CreationTime);
                        Console.WriteLine("Reason = " + history.Reason);
                    }
                }
            }
            catch (ServerException e)
            {
                if (e.RequestId != null)
                {
                    Console.WriteLine("RequestId = " + e.RequestId);
                }
                Console.WriteLine("ErrorCode = " + e.ErrorCode);
                Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
            }
            catch (ClientException e)
            {
                if (e.RequestId != null)
                {
                    Console.WriteLine("RequestId = " + e.RequestId);
                }
                Console.WriteLine("ErrorCode = " + e.ErrorCode);
                Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
            }
            catch (Exception e)
            {
                Console.WriteLine("ErrorMessage = " + e.ToString());
            }
        }

        /// <summary>
        /// Gets the audit history.
        /// </summary>
        /// <returns>The audit history.</returns>
        /// <param name="client">Client.</param>
        public static GetAuditHistoryResponse GetAuditHistory(DefaultAcsClient client) {
            // 构造请求
            GetAuditHistoryRequest request = new GetAuditHistoryRequest();
            request.VideoId = "VideoId";
            request.PageNo = 1;
            request.PageSize = 10;

            return client.GetAcsResponse(request);
        }
    }
}

设置审核安全IP

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

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

using System;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.vod.Model.V20170321;

namespace Aliyun.Acs.vod.Sdk.SetAuditSecurityIp
{
    class MainClass
    {
        /// <summary>
        /// 主函数
        /// </summary>
        /// <param name="args">The command-line arguments.</param>
        public static void Main(string[] args)
        {
            try
            {
                // 初始化客户端
                DefaultAcsClient client = InitVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");

                SetAuditSecurityIpResponse response = SetAuditSecurityIp(client);

                Console.WriteLine("RequestId = " + response.RequestId);
            }
            catch (ServerException e)
            {
                if (e.RequestId != null)
                {
                    Console.WriteLine("RequestId = " + e.RequestId);
                }
                Console.WriteLine("ErrorCode = " + e.ErrorCode);
                Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
            }
            catch (ClientException e)
            {
                if (e.RequestId != null)
                {
                    Console.WriteLine("RequestId = " + e.RequestId);
                }
                Console.WriteLine("ErrorCode = " + e.ErrorCode);
                Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
            }
            catch (Exception e)
            {
                Console.WriteLine("ErrorMessage = " + e.ToString());
            }
        }
        /// <summary>
        /// Sets the audit security ip.
        /// </summary>
        /// <returns>The audit security ip.</returns>
        /// <param name="client">Client.</param>
        public static SetAuditSecurityIpResponse SetAuditSecurityIp (DefaultAcsClient client)
        {
            // 构造请求
            SetAuditSecurityIpRequest request = new SetAuditSecurityIpRequest();
            // 审核安全组名称,默认为Default
            request.SecurityGroupName = "MyGroupName";
            // 操作方式,默认值Append(追加IP白名单)
            request.OperateMode = "Cover";
            // 审核安全IP列表
            request.Ips = "10.23.12.20,10.23.12.21,10.23.12.22";

            return client.GetAcsResponse(request);
        }
    }
}

获取审核安全IP列表

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

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

using System;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.vod.Model.V20170321;

namespace Aliyun.Acs.vod.Sdk.ListAuditSecurityIp
{
    class MainClass
    {
        /// <summary>
        /// The entry point of the program, where the program control starts and ends.
        /// </summary>
        /// <param name="args">The command-line arguments.</param>
        public static void Main(string[] args)
        {
            try
            {
                // 初始化客户端
                DefaultAcsClient client = InitVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
                // 发起请求,并得到 response
                ListAuditSecurityIpResponse response = ListAuditSecurityIp(client);

                Console.WriteLine("RequestId = " + response.RequestId);

                if (response.SecurityIpList != null && response.SecurityIpList.Count > 0)
                {
                    foreach (ListAuditSecurityIpResponse.ListAuditSecurityIp_SecurityIp securityIp in response.SecurityIpList)
                    {
                        Console.WriteLine("SecurityGroupName = " + securityIp.SecurityGroupName);
                        Console.WriteLine("Ips = " + securityIp.Ips);
                        Console.WriteLine("CreationTime = " + securityIp.CreationTime);
                    }
                }
            }
            catch (ServerException e)
            {
                if (e.RequestId != null)
                {
                    Console.WriteLine("RequestId = " + e.RequestId);
                }
                Console.WriteLine("ErrorCode = " + e.ErrorCode);
                Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
            }
            catch (ClientException e)
            {
                if (e.RequestId != null)
                {
                    Console.WriteLine("RequestId = " + e.RequestId);
                }
                Console.WriteLine("ErrorCode = " + e.ErrorCode);
                Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
            }
            catch (Exception e)
            {
                Console.WriteLine("ErrorMessage = " + e.ToString());
            }
        }

        /// <summary>
        /// Lists the audit security ip.
        /// </summary>
        /// <returns>The audit security ip.</returns>
        /// <param name="client">Client.</param>
        public static ListAuditSecurityIpResponse ListAuditSecurityIp(DefaultAcsClient client)
        {
            // 构造请求
            ListAuditSecurityIpRequest request = new ListAuditSecurityIpRequest();
            // 审核安全组名称
            request.SecurityGroupName = "MyGroupName";

            return client.GetAcsResponse(request);
        }
    }
}