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.

package main

import (
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
    "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
    "fmt"
)

func MySubmitAIMediaAuditJob(client *vod.Client) (response *vod.SubmitAIMediaAuditJobResponse, err error) {
    request := vod.CreateSubmitAIMediaAuditJobRequest()
    // Sets the video ID.
    request.MediaId = "<VideoId>" 
    //request.TemplateId = "<TemplateId>" 

    request.AcceptFormat = "JSON"

    return client.SubmitAIMediaAuditJob(request)
}

func main() {
    client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>") 
    if err ! = nil {
        panic(err)
    }

    response, err := MySubmitAIMediaAuditJob(client)
    if err ! = nil {
        panic(err)
    }

    fmt.Println(response.GetHttpContentString())
    fmt.Println(response.JobId)
}

Query an automated review job

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

package main

import (
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
    "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
    "fmt"
)

func MyGetAIMediaAuditJob(client *vod.Client) (response *vod.GetAIMediaAuditJobResponse, err error) {
    request := vod.CreateGetAIMediaAuditJobRequest()
    request.JobId = "<JobId>" 

    request.AcceptFormat = "JSON"

    return client.GetAIMediaAuditJob(request)
}

func main() {
    client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>") 
    if err ! = nil {
        panic(err)
    }

    response, err := MyGetAIMediaAuditJob(client)
    if err ! = nil {
        panic(err)
    }

    fmt.Println(response.GetHttpContentString())
    fmt.Println(response.MediaAuditJob)
}

Obtain the summary of the automated review result

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

package main

import (
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
    "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
    "fmt"
)

func MyGetMediaAuditResult(client *vod.Client) (response *vod.GetMediaAuditResultResponse, err error) {
    request := vod.CreateGetMediaAuditResultRequest()
    request.MediaId = "<VideoId>" 

    request.AcceptFormat = "JSON"

    return client.GetMediaAuditResult(request)
}

func main() {
    client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>") 
    if err ! = nil {
        panic(err)
    }

    response, err := MyGetMediaAuditResult(client)
    if err ! = nil {
        panic(err)
    }

    fmt.Println(response.GetHttpContentString())
    fmt.Println(response.MediaAuditResult.VideoResult)
}

Obtain the details about the automated review result

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

package main

import (
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
    "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
    "fmt"
)

func MyGetMediaAuditResultDetail(client *vod.Client) (response *vod.GetMediaAuditResultDetailResponse, err error) {
    request := vod.CreateGetMediaAuditResultDetailRequest()
    request.MediaId = "<VideoId>" 
    request.PageNo = "1"

    request.AcceptFormat = "JSON"

    return client.GetMediaAuditResultDetail(request)
}

func main() {
    client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>") 
    if err ! = nil {
        panic(err)
    }

    response, err := MyGetMediaAuditResultDetail(client)
    if err ! = nil {
        panic(err)
    }

    fmt.Println(response.GetHttpContentString())
    fmt.Println(response.MediaAuditResultDetail.Total)
    fmt.Println(response.MediaAuditResultDetail.List)
}

Obtain the timeline of the automated review result

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

package main

import (
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
    "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
    "fmt"
)

func MyGetMediaAuditResultTimeline(client *vod.Client) (response *vod.GetMediaAuditResultTimelineResponse, err error) {
    request := vod.CreateGetMediaAuditResultTimelineRequest()
    request.MediaId = "<VideoId>"

    request.AcceptFormat = "JSON"

    return client.GetMediaAuditResultTimeline(request)
}

func main() {
    client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>") 
    if err ! = nil {
        panic(err)
    }

    response, err := MyGetMediaAuditResultTimeline(client)
    if err ! = nil {
        panic(err)
    }

    fmt.Println(response.GetHttpContentString())
    for _, item := range response.MediaAuditResultTimeline.Porn {
        fmt.Printf("%s: %s %s\n", item.Timestamp, item.Label, item.Score)
    }
}

Start a manual review

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

package main

import (
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
    "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
    "fmt"
    "encoding/json"
)

func MyCreateAudit(client *vod.Client) (response *vod.CreateAuditResponse, err error) {
    request := vod.CreateCreateAuditRequest()

    auditContent := []map[string]interface{}{}
    auditItem1 := map[string]interface{}{"VideoId":"<VideoId1>", "Status":"Blocked", "Reason": "porn video"} 
    auditItem2 := map[string]interface{}{"VideoId":"<VideoId2>", "Status":"Normal", "Reason": ""} 
    auditContent = append(auditContent, auditItem1, auditItem2)
    jsonContent, err := json.Marshal(auditContent)
    if err ! = nil {
        fmt.Println("json.Marshal failed:", err)
        return
    }
    request.AuditContent = string(jsonContent)
    request.AcceptFormat = "JSON"

    return client.CreateAudit(request)
}

func main() {
    client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>") 
    if err ! = nil {
        panic(err)
    }

    response, err := MyCreateAudit(client)
    if err ! = nil {
        panic(err)
    }

    fmt.Println(response.GetHttpContentString())
    fmt.Println(response.RequestId)
}

Obtain the manual review history

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

package main

import (
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
    "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
    "fmt"
)

func MyGetAuditHistory(client *vod.Client) (response *vod.GetAuditHistoryResponse, err error) {
    request := vod.CreateGetAuditHistoryRequest()
    request.VideoId = "<VideoId>"
    request.PageNo = "1"
    request.PageSize = "10"
    request.AcceptFormat = "JSON"

    return client.GetAuditHistory(request)
}

func main() {
    client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>") 
    if err ! = nil {
        panic(err)
    }

    response, err := MyGetAuditHistory(client)
    if err ! = nil {
        panic(err)
    }

    fmt.Println(response.GetHttpContentString())
    fmt.Println(response.RequestId)
    for _, history := range response.Histories {
        fmt.Printf("%s: %s\n", history.CreationTime, history.Status)
    }
}

Add IP addresses to review security groups

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

package main

import (
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
    "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
    "fmt"
)

func MySetAuditSecurityIp(client *vod.Client) (response *vod.SetAuditSecurityIpResponse, err error) {
    request := vod.CreateSetAuditSecurityIpRequest()

    // 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. You can add a maximum of 100 IP addresses to each group. Separate multiple IP addresses with a comma (,).
    request. Ips = "10.23.12.20,10.23.12.21,10.23.12.22"

    request.AcceptFormat = "JSON"

    return client.SetAuditSecurityIp(request)
}

func main() {
    client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>") 
    if err ! = nil {
        panic(err)
    }

    response, err := MySetAuditSecurityIp(client)
    if err ! = nil {
        panic(err)
    }

    fmt.Println(response.GetHttpContentString())
    fmt.Println(response.RequestId)
}

Obtain a whitelist of IP addresses in review security groups

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

package main

import (
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
    "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
    "fmt"
)

func MyListAuditSecurityIp(client *vod.Client) (response *vod.ListAuditSecurityIpResponse, err error) {
    request := vod.CreateListAuditSecurityIpRequest()
    request.SecurityGroupName = "MyGroupName"

    request.AcceptFormat = "JSON"

    return client.ListAuditSecurityIp(request)
}

func main() {
    client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>") 
    if err ! = nil {
        panic(err)
    }

    response, err := MyListAuditSecurityIp(client)
    if err ! = nil {
        panic(err)
    }

    fmt.Println(response.GetHttpContentString())
    fmt.Println(response.RequestId)
    for _, ipGroup := range response.SecurityIpList {
        fmt.Printf("%s: %s\n", ipGroup.SecurityGroupName, ipGroup.Ips)
    }
}