全部产品
云市场

媒体审核

更新时间:2019-01-17 20:57:18

初始化客户端

使用前请先初始化客户端,参考 init_vod_client 接口。

提交智能审核作业

接口参数和返回字段请参考 SubmitAIMediaAuditJob

  1. from aliyunsdkvod.request.v20170321 import SubmitAIMediaAuditJobRequest
  2. def submit_ai_media_audit_job(clt):
  3. request = SubmitAIMediaAuditJobRequest.SubmitAIMediaAuditJobRequest()
  4. request.set_MediaId('<VideoId>')
  5. request.set_accept_format('JSON')
  6. response = json.loads(clt.do_action_with_exception(request))
  7. return response
  8. try:
  9. clt = init_vod_client('<AccessKeyId>', '<AccessKeySecret>')
  10. res = submit_ai_media_audit_job(clt)
  11. print(res['JobId'])
  12. print(json.dumps(res, ensure_ascii=False, indent=4))
  13. except Exception as e:
  14. print(e)
  15. print(traceback.format_exc())

查询智能审核作业

接口参数和返回字段请参考 GetAIMediaAuditJob

  1. from aliyunsdkvod.request.v20170321 import GetAIMediaAuditJobRequest
  2. def get_ai_media_audit_job(clt):
  3. request = GetAIMediaAuditJobRequest.GetAIMediaAuditJobRequest()
  4. request.set_JobId('<JobId>')
  5. request.set_accept_format('JSON')
  6. response = json.loads(clt.do_action_with_exception(request))
  7. return response
  8. try:
  9. clt = init_vod_client('<AccessKeyId>', '<AccessKeySecret>')
  10. res = get_ai_media_audit_job(clt)
  11. print(res['MediaAuditJob'])
  12. print(json.dumps(res, ensure_ascii=False, indent=4))
  13. except Exception as e:
  14. print(e)
  15. print(traceback.format_exc())

获取智能审核结果摘要

接口参数和返回字段请参考 GetMediaAuditResult

  1. from aliyunsdkvod.request.v20170321 import GetMediaAuditResultRequest
  2. def get_media_audit_result(clt):
  3. request = GetMediaAuditResultRequest.GetMediaAuditResultRequest()
  4. request.set_MediaId('<VideoId>')
  5. request.set_accept_format('JSON')
  6. response = json.loads(clt.do_action_with_exception(request))
  7. return response
  8. try:
  9. clt = init_vod_client('<AccessKeyId>', '<AccessKeySecret>')
  10. res = get_media_audit_result(clt)
  11. print(res['MediaAuditResult'])
  12. print(json.dumps(res, ensure_ascii=False, indent=4))
  13. except Exception as e:
  14. print(e)
  15. print(traceback.format_exc())

获取智能审核结果详情

接口参数和返回字段请参考 GetMediaAuditResultDetail

  1. from aliyunsdkvod.request.v20170321 import GetMediaAuditResultDetailRequest
  2. def get_media_audit_result_detail(clt):
  3. request = GetMediaAuditResultDetailRequest.GetMediaAuditResultDetailRequest()
  4. request.set_MediaId('<VideoId>')
  5. request.set_PageNo(1)
  6. request.set_accept_format('JSON')
  7. response = json.loads(clt.do_action_with_exception(request))
  8. return response
  9. try:
  10. clt = init_vod_client('<AccessKeyId>', '<AccessKeySecret>')
  11. res = get_media_audit_result_detail(clt)
  12. print(res['MediaAuditResultDetail']['Total'])
  13. print(json.dumps(res, ensure_ascii=False, indent=4))
  14. except Exception as e:
  15. print(e)
  16. print(traceback.format_exc())

获取智能审核结果时间线

接口参数和返回字段请参考 GetMediaAuditResultTimeline

  1. from aliyunsdkvod.request.v20170321 import GetMediaAuditResultTimelineRequest
  2. def get_media_audit_result_timeline(clt):
  3. request = GetMediaAuditResultTimelineRequest.GetMediaAuditResultTimelineRequest()
  4. request.set_MediaId('<VideoId>')
  5. request.set_accept_format('JSON')
  6. response = json.loads(clt.do_action_with_exception(request))
  7. return response
  8. try:
  9. clt = init_vod_client('<AccessKeyId>', '<AccessKeySecret>')
  10. res = get_media_audit_result_timeline(clt)
  11. print(res['MediaAuditResultTimeline']['Porn'])
  12. print(json.dumps(res, ensure_ascii=False, indent=4))
  13. except Exception as e:
  14. print(e)
  15. print(traceback.format_exc())

人工审核

接口参数和返回字段请参考 CreateAudit

  1. from aliyunsdkvod.request.v20170321 import CreateAuditRequest
  2. def create_audit(clt):
  3. request = CreateAuditRequest.CreateAuditRequest()
  4. auditContent = []
  5. # 分别指定视频ID、审核状态和审核理由
  6. auditItem = {'VideoId': '<videoId>', 'Status': 'Blocked', 'Reason': 'porn video'}
  7. auditContent.append(auditItem)
  8. request.set_AuditContent(json.dumps(auditContent))
  9. request.set_accept_format('JSON')
  10. response = json.loads(clt.do_action_with_exception(request))
  11. return response
  12. try:
  13. clt = init_vod_client('<AccessKeyId>', '<AccessKeySecret>')
  14. res = create_audit(clt)
  15. print(json.dumps(res, ensure_ascii=False, indent=4))
  16. except Exception as e:
  17. print(e)
  18. print(traceback.format_exc())

获取人工审核历史

接口参数和返回字段请参考 GetAuditHistory

  1. from aliyunsdkvod.request.v20170321 import GetAuditHistoryRequest
  2. def get_audit_history(clt):
  3. request = GetAuditHistoryRequest.GetAuditHistoryRequest()
  4. request.set_VideoId('<videoId>')
  5. request.set_PageNo(1)
  6. request.set_PageSize(10)
  7. request.set_accept_format('JSON')
  8. response = json.loads(clt.do_action_with_exception(request))
  9. return response
  10. try:
  11. clt = init_vod_client('<AccessKeyId>', '<AccessKeySecret>')
  12. history = get_audit_history(clt)
  13. print(history['Histories'])
  14. print(json.dumps(history, ensure_ascii=False, indent=4))
  15. except Exception as e:
  16. print(e)
  17. print(traceback.format_exc())

设置审核安全IP

接口参数和返回字段请参考 SetAuditSecurityIp

  1. from aliyunsdkvod.request.v20170321 import SetAuditSecurityIpRequest
  2. def set_audit_security_ip(clt):
  3. request = SetAuditSecurityIpRequest.SetAuditSecurityIpRequest()
  4. # 审核安全组名称,默认为Default
  5. request.set_SecurityGroupName('MyGroupName')
  6. # 操作方式,默认值Append(追加IP白名单)
  7. request.set_OperateMode('Cover')
  8. # 审核安全IP列表,每个分组最多支持100个并以逗号分隔
  9. request.set_Ips('10.23.12.20,10.23.12.21,10.23.12.22')
  10. request.set_accept_format('JSON')
  11. response = json.loads(clt.do_action_with_exception(request))
  12. return response
  13. try:
  14. clt = init_vod_client('<AccessKeyId>', '<AccessKeySecret>')
  15. res = set_audit_security_ip(clt)
  16. print(json.dumps(res, ensure_ascii=False, indent=4))
  17. except Exception as e:
  18. print(e)
  19. print(traceback.format_exc())

获取审核安全IP列表

接口参数和返回字段请参考 ListAuditSecurityIp

  1. from aliyunsdkvod.request.v20170321 import ListAuditSecurityIpRequest
  2. def list_audit_security_ip(clt):
  3. request = ListAuditSecurityIpRequest.ListAuditSecurityIpRequest()
  4. # 审核安全组名称
  5. request.set_SecurityGroupName('MyGroupName')
  6. request.set_accept_format('JSON')
  7. response = json.loads(clt.do_action_with_exception(request))
  8. return response
  9. try:
  10. clt = init_vod_client('<AccessKeyId>', '<AccessKeySecret>')
  11. ips = list_audit_security_ip(clt)
  12. print(ips['SecurityIpList'])
  13. print(json.dumps(ips, ensure_ascii=False, indent=4))
  14. except Exception as e:
  15. print(e)
  16. print(traceback.format_exc())