全部产品

媒体审核

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

初始化客户端

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

提交智能审核作业

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

接口参数和返回字段请参见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())

查询智能审核作业

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

接口参数和返回字段请参见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())

获取智能审核结果摘要

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

接口参数和返回字段请参见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())

获取智能审核结果详情

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

接口参数和返回字段请参见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())

获取智能审核结果时间线

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

接口参数和返回字段请参见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())

人工审核

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

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

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

    auditContent = []
    # 分别指定视频ID、审核状态和审核理由
    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())

获取人工审核历史

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

接口参数和返回字段请参见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())

设置审核安全IP

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

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

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

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

获取审核安全IP列表

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

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

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

    # 审核安全组名称
    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())