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 init_vod_client.

Submit an automated review job

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

from aliyunsdkvod.request.v20170321 import SubmitAIMediaAuditJobRequest
def submit_ai_media_audit_job(clt):
    request = SubmitAIMediaAuditJobRequest.SubmitAIMediaAuditJobRequest()
    request.set_MediaId('<VideoId>') 

    request.set_accept_format('JSON')
    response = json.loads(clt.do_action_with_exception(request))
    return response

try:
    clt = init_vod_client('<AccessKeyId>', '<AccessKeySecret>') 
    res = submit_ai_media_audit_job(clt)
    print(res['JobId'])
    print(json.dumps(res, ensure_ascii=False, indent=4))

except Exception as e:
    print(e)
    print(traceback.format_exc())

Query an automated review job

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

from aliyunsdkvod.request.v20170321 import GetAIMediaAuditJobRequest
def get_ai_media_audit_job(clt):
    request = GetAIMediaAuditJobRequest.GetAIMediaAuditJobRequest()
    request.set_JobId('<JobId>')

    request.set_accept_format('JSON')
    response = json.loads(clt.do_action_with_exception(request))
    return response

try:
    clt = init_vod_client('<AccessKeyId>', '<AccessKeySecret>') 
    res = get_ai_media_audit_job(clt)
    print(res['MediaAuditJob'])
    print(json.dumps(res, ensure_ascii=False, indent=4))

except Exception as e:
    print(e)
    print(traceback.format_exc())

Obtain the summary of the automated review result

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

from aliyunsdkvod.request.v20170321 import GetMediaAuditResultRequest
def get_media_audit_result(clt):
    request = GetMediaAuditResultRequest.GetMediaAuditResultRequest()
    request.set_MediaId('<VideoId>') 

    request.set_accept_format('JSON')
    response = json.loads(clt.do_action_with_exception(request))
    return response

try:
    clt = init_vod_client('<AccessKeyId>', '<AccessKeySecret>') 
    res = get_media_audit_result(clt)
    print(res['MediaAuditResult'])
    print(json.dumps(res, ensure_ascii=False, indent=4))

except Exception as e:
    print(e)
    print(traceback.format_exc())

Obtain the details about the automated review result

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

from aliyunsdkvod.request.v20170321 import GetMediaAuditResultDetailRequest
def get_media_audit_result_detail(clt):
    request = GetMediaAuditResultDetailRequest.GetMediaAuditResultDetailRequest()
    request.set_MediaId('<VideoId>') 
    request.set_PageNo(1)

    request.set_accept_format('JSON')
    response = json.loads(clt.do_action_with_exception(request))
    return response

try:
    clt = init_vod_client('<AccessKeyId>', '<AccessKeySecret>') 
    res = get_media_audit_result_detail(clt)
    print(res['MediaAuditResultDetail']['Total'])
    print(json.dumps(res, ensure_ascii=False, indent=4))

except Exception as e:
    print(e)
    print(traceback.format_exc())

Obtain the timeline of the automated review result

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

from aliyunsdkvod.request.v20170321 import GetMediaAuditResultTimelineRequest
def get_media_audit_result_timeline(clt):
    request = GetMediaAuditResultTimelineRequest.GetMediaAuditResultTimelineRequest()
    request.set_MediaId('<VideoId>') 

    request.set_accept_format('JSON')
    response = json.loads(clt.do_action_with_exception(request))
    return response

try:
    clt = init_vod_client('<AccessKeyId>', '<AccessKeySecret>') 
    res = get_media_audit_result_timeline(clt)
    print(res['MediaAuditResultTimeline']['Porn'])
    print(json.dumps(res, ensure_ascii=False, indent=4))

except Exception as e:
    print(e)
    print(traceback.format_exc())

Start a manual review

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

from aliyunsdkvod.request.v20170321 import CreateAuditRequest
def create_audit(clt):
    request = CreateAuditRequest.CreateAuditRequest()

    auditContent = []
    # Sets the video ID and review status. Specifies the reason for blocking the video if the Status parameter is set to Blocked.
    auditItem = {'VideoId': '<videoId>', 'Status': 'Blocked', 'Reason': 'porn video'} 
    auditContent.append(auditItem)
    request.set_AuditContent(json.dumps(auditContent))

    request.set_accept_format('JSON')
    response = json.loads(clt.do_action_with_exception(request))
    return response

try:
    clt = init_vod_client('<AccessKeyId>', '<AccessKeySecret>') 
    res = create_audit(clt)
    print(json.dumps(res, ensure_ascii=False, indent=4))

except Exception as e:
    print(e)
    print(traceback.format_exc())

Obtain the manual review history

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

from aliyunsdkvod.request.v20170321 import GetAuditHistoryRequest
def get_audit_history(clt):
    request = GetAuditHistoryRequest.GetAuditHistoryRequest()

    request.set_VideoId('<videoId>') 
    request.set_PageNo(1)
    request.set_PageSize(10)

    request.set_accept_format('JSON')
    response = json.loads(clt.do_action_with_exception(request))
    return response

try:
    clt = init_vod_client('<AccessKeyId>', '<AccessKeySecret>') 
    history = get_audit_history(clt)
    print(history['Histories'])
    print(json.dumps(history, ensure_ascii=False, indent=4))

except Exception as e:
    print(e)
    print(traceback.format_exc())

Add IP addresses to review security groups

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

from aliyunsdkvod.request.v20170321 import SetAuditSecurityIpRequest
def set_audit_security_ip(clt):
    request = SetAuditSecurityIpRequest.SetAuditSecurityIpRequest()

    # Sets the name of each review security group. Default value: Default.
    request.set_SecurityGroupName('MyGroupName')
    # Sets the write mode. The default value Append indicates that new IP addresses are appended to the whitelist.
    request.set_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.set_Ips('10.23.12.20,10.23.12.21,10.23.12.22')

    request.set_accept_format('JSON')
    response = json.loads(clt.do_action_with_exception(request))
    return response

try:
    clt = init_vod_client('<AccessKeyId>', '<AccessKeySecret>') 
    res = set_audit_security_ip(clt)
    print(json.dumps(res, ensure_ascii=False, indent=4))

except Exception as e:
    print(e)
    print(traceback.format_exc())

Obtain a whitelist of IP addresses in review security groups

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

from aliyunsdkvod.request.v20170321 import ListAuditSecurityIpRequest
def list_audit_security_ip(clt):
    request = ListAuditSecurityIpRequest.ListAuditSecurityIpRequest()

    # Sets the name of each review security group.
    request.set_SecurityGroupName('MyGroupName')

    request.set_accept_format('JSON')
    response = json.loads(clt.do_action_with_exception(request))
    return response

try:
    clt = init_vod_client('<AccessKeyId>', '<AccessKeySecret>') 
    ips = list_audit_security_ip(clt)
    print(ips['SecurityIpList'])
    print(json.dumps(ips, ensure_ascii=False, indent=4))

except Exception as e:
    print(e)
    print(traceback.format_exc())