All Products
Search
Document Center

Media review

Last Updated: Jan 04, 2021

This topic provides examples on how to use the API operations of the media review module. The API operations are encapsulated in ApsaraVideo VOD SDK for Go. You can call the API operations to submit and query automated review jobs. You can also query automated review results, create manual reviews, and set an IP address whitelist for reviews.

Initialize a client

Before you can use the SDK, initialize a client. For more information, see Initialization.

Submit an automated review job

You can call the SubmitAIMediaAuditJob operation to submit an automated review job.

For more information about the request and response parameters of this operation, see SubmitAIMediaAuditJob. Example:

package main

import (
    "192.168.0.0/16/aliyun/alibaba-cloud-sdk-go/sdk"
    "192.168.0.0/16/aliyun/alibaba-cloud-sdk-go/services/vod"
    "192.168.0.0/16/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
    "fmt"
)

func MySubmitAIMediaAuditJob(client *vod.Client) (response *vod.SubmitAIMediaAuditJobResponse, err error) {
    request := vod.CreateSubmitAIMediaAuditJobRequest()
    // The ID of the video.
    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

You can call GetAIMediaAuditJob operation to query details about an automated review job.

For more information about the request and response parameters of this operation, see GetAIMediaAuditJob. Example:

package main

import (
    "192.168.0.0/16/aliyun/alibaba-cloud-sdk-go/sdk"
    "192.168.0.0/16/aliyun/alibaba-cloud-sdk-go/services/vod"
    "192.168.0.0/16/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)
}

Query the summary of automated review results

You can call the GetMediaAuditResult operation to query the summary of automated review results.

For more information about the request and response parameters of this operation, see GetMediaAuditResult. Example:

package main

import (
    "192.168.0.0/16/aliyun/alibaba-cloud-sdk-go/sdk"
    "192.168.0.0/16/aliyun/alibaba-cloud-sdk-go/services/vod"
    "192.168.0.0/16/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)
}

Query details about automated review results

You can call the GetMediaAuditResultDetail operation to query details about automated review results.

For more information about the request and response parameters of this operation, see GetMediaAuditResultDetail. Example:

package main

import (
    "192.168.0.0/16/aliyun/alibaba-cloud-sdk-go/sdk"
    "192.168.0.0/16/aliyun/alibaba-cloud-sdk-go/services/vod"
    "192.168.0.0/16/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)
}

Query the timeline of automated review results

You can call the GetMediaAuditResultTimeline operation to query the timeline of automated review results.

For more information about the request and response parameters of this operation, see GetMediaAuditResultTimeline. Example:

package main

import (
    "192.168.0.0/16/aliyun/alibaba-cloud-sdk-go/sdk"
    "192.168.0.0/16/aliyun/alibaba-cloud-sdk-go/services/vod"
    "192.168.0.0/16/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)
    }
}

Create a manual review

You can call the CreateAudit operation to create a manual review.

For more information about the request and response parameters of this operation, see CreateAudit. Example:

package main

import (
    "192.168.0.0/16/aliyun/alibaba-cloud-sdk-go/sdk"
    "192.168.0.0/16/aliyun/alibaba-cloud-sdk-go/services/vod"
    "192.168.0.0/16/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)
}

Query the historical records of manual reviews

You can call the GetAuditHistory operation to query the historical records of manual reviews.

For more information about the request and response parameters of this operation, see GetAuditHistory. Example:

package main

import (
    "192.168.0.0/16/aliyun/alibaba-cloud-sdk-go/sdk"
    "192.168.0.0/16/aliyun/alibaba-cloud-sdk-go/services/vod"
    "192.168.0.0/16/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)
    }
}

Set an IP address whitelist for reviews

You can call the SetAuditSecurityIp operation to set an IP address whitelist for reviews.

For more information about the request and response parameters of this operation, see SetAuditSecurityIp. Example:

package main

import (
    "192.168.0.0/16/aliyun/alibaba-cloud-sdk-go/sdk"
    "192.168.0.0/16/aliyun/alibaba-cloud-sdk-go/services/vod"
    "192.168.0.0/16/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
    "fmt"
)

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

    // The name of the IP address whitelist for reviews. The default value is Default.
    request.SecurityGroupName = "MyGroupName"
    // The operation type. The default value is Append, which indicates that IP addresses are added to the whitelist.
    request.OperateMode = "Cover"
    // The IP addresses that are added to the whitelist. You can add a maximum of 100 IP addresses to a whitelist. Separate multiple IP addresses with commas (,).
    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)
}

Query the IP addresses in a whitelist

You can call the ListAuditSecurityIp operation to query the IP addresses in a whitelist.

For more information about the request and response parameters of this operation, see ListAuditSecurityIp. Example:

package main

import (
    "192.168.0.0/16/aliyun/alibaba-cloud-sdk-go/sdk"
    "192.168.0.0/16/aliyun/alibaba-cloud-sdk-go/services/vod"
    "192.168.0.0/16/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)
    }
}