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.

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
            {
                // Initializes the client.
                DefaultAcsClient client = InitVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
                // Initiates the request and obtains a 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>
        /// Submits an automated review job.
        /// </summary>
        /// <param name="client">The client.</param>
        /// <summary>
        /// Submits an automated review job.
        /// </summary>
        /// <returns>The ID of the automated review job.</returns>
        /// <param name="client">The client.</param>
        public static SubmitAIMediaAuditJobResponse SubmitAIMediaAuditJob(DefaultAcsClient client)
        {
        // Constructs a request.
        SubmitAIMediaAuditJobRequest request = new SubmitAIMediaAuditJobRequest();
        // Sets the video ID.
        request.MediaId = "dc063078c1d845139e2a5bd8ffxxxxxx";
        // Obtains a response.
        return client.GetAcsResponse(request);
        }
    }
}

Query an automated review job

For more information about the request and response parameters, see 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
            {
                // Initializes the client.
                DefaultAcsClient client = InitVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
                // Initiates the request and obtains a response.
                GetAIMediaAuditJobResponse response = GetAIMediaAuditJob(client);
                // The GUID generated by Alibaba Cloud for the request.
                Console.WriteLine("RequestId = " + response.RequestId);
                // The job information.
                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>
        /// Queries an automated review job.
        /// </summary>
        /// <returns>The information about the automated review job.</returns>
        /// <param name="client">The client. </param>
        public static GetAIMediaAuditJobResponse GetAIMediaAuditJob(DefaultAcsClient client)
        {
            // Constructs a request.
            GetAIMediaAuditJobRequest request = new GetAIMediaAuditJobRequest();
            // Sets the job ID.
            request.JobId = "7dc69b893c8b4f13b47aae8de0xxxxxx";
            // Obtains a response.
            return client.GetAcsResponse(request);

        }
    }
}

Obtain the summary of the automated review result

For more information about the request and response parameters, see 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
            {
                // Initializes the client.
                DefaultAcsClient client = InitVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
                // Initiates the request and obtains a response.
                GetMediaAuditResultResponse response = GetMediaAuditResult(client);
                // The GUID generated by Alibaba Cloud for the request.
                Console.WriteLine("RequestId = " + response.RequestId);
                // The review result information.
                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>
        /// Obtains the summary of automated review result.
        /// </summary>
        /// <returns>The summary of automated review result.</returns>
        /// <param name="client">The client. </param>
        public static GetMediaAuditResultResponse GetMediaAuditResult(DefaultAcsClient client)
        {
            // Constructs a request.
            GetMediaAuditResultRequest request = new GetMediaAuditResultRequest();
            // Sets the video ID.
            request.MediaId = "7dc69b893c8b4f13b47aae8de0xxxxxx";
            // Obtains a response.
            return client.GetAcsResponse(request);

        }
    }
}

Obtain the details about the automated review result

For more information about the request and response parameters, see 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
            {
                // Initializes the client.
                DefaultAcsClient client = InitVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
                // Initiates the request and obtains a response.
                GetMediaAuditResultDetailResponse response = GetMediaAuditResultDetail(client);
                // The GUID generated by Alibaba Cloud for the request.
                Console.WriteLine("RequestId = " + response.RequestId);
                // The review result information.
                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>
        /// Obtains the details about automated review result.
        /// </summary>
        /// <returns>The details about automated review result.</returns>
        /// <param name="client">The client.</param>
        public static GetMediaAuditResultDetailResponse GetMediaAuditResultDetail(DefaultAcsClient client)
        {
            // Constructs a request.
            GetMediaAuditResultDetailRequest request = new GetMediaAuditResultDetailRequest();
            // Sets the video ID.
            request.MediaId = "7dc69b893c8b4f13b47aae8de0xxxxxx";
            // Sets the page number.
            request.PageNo = 1;
            // Obtains a response.
            return client.GetAcsResponse(request);

        }
    }
}

Obtain the timeline of the automated review result

For more information about the request and response parameters, see 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
            {
                // Initializes the client.
                DefaultAcsClient client = InitVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
                // Initiates the request and obtains a response.
                GetMediaAuditResultTimelineResponse response = GetMediaAuditResultTimeline(client);
                // The GUID generated by Alibaba Cloud for the request.
                Console.WriteLine("RequestId = " + response.RequestId);
                // The review result information.
                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>
        /// Obtains the timeline of automated review result.
        /// </summary>
        /// <returns>The timeline of automated review result.</returns>
        /// <param name="client">The client. </param>
        public static GetMediaAuditResultTimelineResponse GetMediaAuditResultTimeline(DefaultAcsClient client)
        {
            // Constructs a request.
            GetMediaAuditResultTimelineRequest request = new GetMediaAuditResultTimelineRequest();
            // Sets the video ID.
            request.MediaId = "7dc69b893c8b4f13b47aae8de0xxxxxx";
            // Obtains a response.
            return client.GetAcsResponse(request);

        }
    }
}

Start a manual review

For more information about the request and response parameters, see 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
            {
                // Initializes the client.
                DefaultAcsClient client = InitVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
                // Initiates the request and obtains a 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>
        /// Starts manual review.
        /// </summary>
        /// <returns>The manual review.</returns>
        /// <param name="client">The client. </param>
        public static CreateAuditResponse CreateAudit(DefaultAcsClient client) 
        {
            CreateAuditRequest request = new CreateAuditRequest();
            // Sets the manual review content.
            request.AuditContent = BuildAuditContent();

            return client.GetAcsResponse(request);
        }

        /// <summary>
        /// Constructs the manual review content.
        /// </summary>
        /// <returns>The manual review content.</returns>
        public static string BuildAuditContent() 
        {
            JArray auditContents = new JArray();
            JObject auditContent = new JObject();
            auditContent.Add("VideoId", "3ebc10160bda481ca9b6858a0bxxxxxx");
            auditContent.Add("Status", "Blocked");
            auditContent.Add("Reason", "porn video");

            return auditContents.ToString();
        }
    }
}

Obtain the manual review history

For more information about the request and response parameters, see 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
            {
                // Initializes the client.
                DefaultAcsClient client = InitVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
                // Initiates the request and obtains a response.
                GetAuditHistoryResponse response = GetAuditHistory(client);
                Console.WriteLine("RequestId = " + response.RequestId);
                // The latest manual review result.
                Console.WriteLine("Status = " + response.Status);
                // The number of records in the manual review history.
                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>
        /// Obtains the manual review history.
        /// </summary>
        /// <returns>The manual review history.</returns>
        /// <param name="client">The client.</param>
        public static GetAuditHistoryResponse GetAuditHistory(DefaultAcsClient client) {
            // Constructs a request.
            GetAuditHistoryRequest request = new GetAuditHistoryRequest();
            request.VideoId = "VideoId";
            request.PageNo = 1;
            request.PageSize = 10;

            return client.GetAcsResponse(request);
        }
    }
}

Add IP addresses to review security groups

For more information about the request and response parameters, see 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>
        /// The main method.
        /// </summary>
        /// <param name="args">The command-line arguments.</param>
        public static void Main(string[] args)
        {
            try
            {
                // Initializes the client.
                DefaultAcsClient client = InitVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");

                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>
        /// Adds IP addresses to review security groups.
        /// </summary>
        /// <returns>The whitelist of IP addresses in review security groups.</returns>
        /// <param name="client">The client.</param>
        public static SetAuditSecurityIpResponse SetAuditSecurityIp (DefaultAcsClient client)
        {
            // Constructs a request.
            SetAuditSecurityIpRequest request = new SetAuditSecurityIpRequest();
            // Sets the name of each review security group. Default value: Default.
            request.SecurityGroupName = "MyGroupName";
            // Sets the write mode. The default value Append indicates that new IP addresses are appended to the whitelist.
            request.OperateMode = "Cover";
            // Sets the whitelist of IP addresses in each review security group.
            request.Ips = "10.23.12.20,10.23.12.21,10.23.12.22";

            return client.GetAcsResponse(request);
        }
    }
}

Obtain a whitelist of IP addresses in review security groups

For more information about the request and response parameters, see 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
            {
                // Initializes the client.
                DefaultAcsClient client = InitVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
                // Initiates the request and obtains a 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>
        /// Obtains a whitelist of IP addresses in review security groups.
        /// </summary>
        /// <returns>The whitelist of IP addresses in automated review security groups.</returns>
        /// <param name="client">The client.</param>
        public static ListAuditSecurityIpResponse ListAuditSecurityIp(DefaultAcsClient client)
        {
            // Constructs a request.
            ListAuditSecurityIpRequest request = new ListAuditSecurityIpRequest();
            // Sets the name of each review security group.
            request.SecurityGroupName = "MyGroupName";

            return client.GetAcsResponse(request);
        }
    }
}