This topic describes how to perform a manual video review using the Python software development kit (SDK).
Feature description
If the results of machine-assisted moderation for a video do not meet your expectations, you can use the video manual review API. For more information about the parameters, see the Video Manual Review API documentation.
You can call this SDK operation using the Content Moderation API endpoint. For more information about API endpoints, see Endpoints.
Prerequisites
Python dependencies are installed. For more information, see Installation.
NoteYou must use the required Python version described in the Installation topic to install the dependencies. Otherwise, subsequent operation calls fail.
The Extension.Uploader utility class is downloaded and imported into your project.
Submit a manual video review task
# coding=utf-8
import uuid
from aliyunsdkcore import client
from aliyunsdkcore.profile import region_provider
from aliyunsdkgreen.request.v20180509 import VideoAsyncManualScanRequest
import json
# Note: To improve moderation performance, reuse the instantiated client. This avoids repeatedly establishing connections.
# Common methods to obtain environment variables:
# Obtain the AccessKey ID of the RAM user: os.environ['ALIBABA_CLOUD_ACCESS_KEY_ID']
# Obtain the AccessKey secret of the RAM user: os.environ['ALIBABA_CLOUD_ACCESS_KEY_SECRET']
clt = client.AcsClient("Obtain the AccessKey ID from an environment variable", "Obtain the AccessKey secret from an environment variable", "cn-shanghai")
region_provider.modify_point('Green', 'cn-shanghai', 'green.cn-shanghai.aliyuncs.com')
request = VideoAsyncManualScanRequest.VideoAsyncManualScanRequest()
request.set_accept_format('JSON')
request.set_content(json.dumps({"tasks": [{"dataId": "Data ID for moderation", "url": "URL of the video to be moderated"}],
"callback": "Webhook address",
"seed": "Random string"}))
try:
response = clt.do_action_with_exception(request)
print response
except Exception, err:
print err.__str__()Query the result of a manual video review task
# coding=utf-8
import uuid
from aliyunsdkcore import client
from aliyunsdkcore.profile import region_provider
from aliyunsdkgreen.request.v20180509 import VideoAsyncManualScanResultsRequest
import json
# Note: To improve moderation performance, reuse the instantiated client. This avoids repeatedly establishing connections.
# Common methods to obtain environment variables:
# Obtain the AccessKey ID of the RAM user: os.environ['ALIBABA_CLOUD_ACCESS_KEY_ID']
# Obtain the AccessKey secret of the RAM user: os.environ['ALIBABA_CLOUD_ACCESS_KEY_SECRET']
clt = client.AcsClient("Obtain the AccessKey ID from an environment variable", "Obtain the AccessKey secret from an environment variable", "cn-shanghai")
region_provider.modify_point('Green', 'cn-shanghai', 'green.cn-shanghai.aliyuncs.com')
request = VideoAsyncManualScanResultsRequest.VideoAsyncManualScanResultsRequest()
request.set_accept_format('JSON')
request.set_content(json.dumps(["Manual video review task ID"]))
try:
response = clt.do_action_with_exception(request)
print response
except Exception, err:
print err.__str__()