全部产品

媒体审核

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

初始化客户端

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

提交智能审核作业

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

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

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()
    // 设置视频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)
}

查询智能审核作业

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

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

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)
}

获取智能审核结果摘要

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

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

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)
}

获取智能审核结果详情

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

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

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)
}

获取智能审核结果时间线

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

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

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)
    }
}

人工审核

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

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

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)
}

获取人工审核历史

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

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

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)
    }
}

设置审核安全IP

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

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

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()

    // 审核安全组名称,默认为Default
    request.SecurityGroupName = "MyGroupName"
    // 操作方式,默认值Append(追加IP白名单)
    request.OperateMode = "Cover"
    // 审核安全IP列表,每个分组最多支持100个并以逗号分隔
    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)
}

获取审核安全IP列表

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

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

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)
    }
}