Manual video review

Updated at:

This topic describes how to use the Go software development kit (SDK) to call the manual video review API.

Features

If the video moderation results do not meet your expectations, you can use manual review. For more information about the parameters, see Manual video review API.

Use the API endpoint for AI Guardrails to call the SDK. For more information about API endpoints, see Endpoints.

Note
  • This SDK only supports public video URLs. Local files or binary data are not supported.

  • Supported URL types:

    • Public HTTP/HTTPS URLs with a maximum length of 2,048 characters.

    • Alibaba Cloud OSS URLs: oss://<bucket-name>.<endpoint>/<object-name>. You must authorize Content Moderation to access the target OSS bucket, and the bucket must be in the same region as the Content Moderation service. For more information, see Authorize Content Moderation to access OSS storage space.

Prerequisites

Before you begin, make sure you have:

  • Installed Go dependencies. See Installation for the required Go version. Using an unsupported version causes subsequent operation calls to fail.

  • A RAM user AccessKey ID and AccessKey secret stored as environment variables:

    • ALIBABA_CLOUD_ACCESS_KEY_ID

    • ALIBABA_CLOUD_ACCESS_KEY_SECRET

Submit a manual video review task

package main

import (
   "encoding/json"
   "fmt"
   "github.com/aliyun/alibaba-cloud-sdk-go/services/green"
   "strconv"
)

func main() {
   /**
    * Note: To improve moderation performance, reuse the client instance. This avoids repeatedly establishing connections.
    * Common ways to get environment variables:
    *     Get the AccessKey ID of the Resource Access Management (RAM) user: os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_ID")
    *     Get the AccessKey secret of the RAM user: os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET")
    */
   client, _err := green.NewClientWithAccessKey(
        "cn-shanghai", 
        "Obtain the AccessKey ID of the RAM user from an environment variable.", 
        "Obtain the AccessKey secret of the RAM user from an environment variable.")
   if _err != nil {
      fmt.Println(_err.Error())
      return
   }
   task := map[string]interface{}{"dataId": "Data ID", "url": "URL of the video to be moderated"}
  // The callback and seed parameters are optional. They are used for webhook notifications.
   content, _ := json.Marshal(
      map[string]interface{}{
         "tasks":    [...]map[string]interface{}{task},
         "callback": "Webhook address", "seed": "Random string",
      },
   )

   request := green.CreateVideoAsyncManualScanRequest()
   request.SetContent(content)
   response, err := client.VideoAsyncManualScan(request)
   if err != nil {
      fmt.Println(err.Error())
      return
   }
   if response.GetHttpStatus() != 200 {
      fmt.Println("response not success. status:" + strconv.Itoa(response.GetHttpStatus()))
   }
   fmt.Println(response.GetHttpContentString())
}

Query the result of a manual video review task

package main

import (
   "encoding/json"
   "fmt"
   "github.com/aliyun/alibaba-cloud-sdk-go/services/green"
   "strconv"
)

func main() {
   /**
    * Note: To improve moderation performance, reuse the client instance. This avoids repeatedly establishing connections.
    * Common ways to get environment variables:
    *     Get the AccessKey ID of the RAM user: os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_ID")
    *     Get the AccessKey secret of the RAM user: os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET")
    */
   client, _err := green.NewClientWithAccessKey(
        "cn-shanghai", 
        "Obtain the AccessKey ID of the RAM user from an environment variable.", 
        "Obtain the AccessKey secret of the RAM user from an environment variable.")
   if _err != nil {
      fmt.Println(_err.Error())
      return
   }

   content, _ := json.Marshal([...]string{"ID of the manual video review task"})

   request := green.CreateVideoAsyncManualScanResultsRequest()
   request.SetContent(content)
   response, err := client.VideoAsyncManualScanResults(request)
   if err != nil {
      fmt.Println(err.Error())
      return
   }
   if response.GetHttpStatus() != 200 {
      fmt.Println("response not success. status:" + strconv.Itoa(response.GetHttpStatus()))
   }
   fmt.Println(response.GetHttpContentString())
}