All Products
Search
Document Center

Media content moderation

Last Updated: May 27, 2020

Initialize a client

Initialize a client before using the SDK. For more information, see init_vod_client.

Submit an automated review job

  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())

Query an automated review job

  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())

Obtain the summary of the automated review result

  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())

Obtain the details about the automated review result

  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())

Obtain the timeline of the automated review result

  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())

Start a manual review

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

  1. from aliyunsdkvod.request.v20170321 import CreateAuditRequest
  2. def create_audit(clt):
  3. request = CreateAuditRequest.CreateAuditRequest()
  4. auditContent = []
  5. # Sets the video ID and review status. Specifies the reason for blocking the video if the Status parameter is set to Blocked.
  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())

Obtain the manual review history

For more information about the request and response parameters, see 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())

Add IP addresses to review security groups

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

  1. from aliyunsdkvod.request.v20170321 import SetAuditSecurityIpRequest
  2. def set_audit_security_ip(clt):
  3. request = SetAuditSecurityIpRequest.SetAuditSecurityIpRequest()
  4. # Sets the name of each review security group. Default value: Default.
  5. request.set_SecurityGroupName('MyGroupName')
  6. # Sets the write mode. The default value Append indicates that new IP addresses are appended to the whitelist.
  7. request.set_OperateMode('Cover')
  8. # 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 (,).
  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())

Obtain a whitelist of IP addresses in review security groups

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

  1. from aliyunsdkvod.request.v20170321 import ListAuditSecurityIpRequest
  2. def list_audit_security_ip(clt):
  3. request = ListAuditSecurityIpRequest.ListAuditSecurityIpRequest()
  4. # Sets the name of each review security group.
  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())