@@ -511,7 +511,25 @@ def get_object_sensitive_content_recognition(self, Bucket, Key, DetectType, Inte
511511 params = params ,
512512 headers = headers )
513513
514+ logging .debug ("get object sensitive content recognition rsp:%s" , rt .content )
514515 data = xml_to_dict (rt .content )
516+ # format res
517+ if 'PornInfo' in data :
518+ if 'OcrResults' in data ['PornInfo' ]:
519+ format_dict_or_list (data ['PornInfo' ]['OcrResults' ], ['Keywords' ])
520+ format_dict (data ['PornInfo' ], ['OcrResults' , 'ObjectResults' ])
521+ if 'TerroristInfo' in data :
522+ if 'OcrResults' in data ['TerroristInfo' ]:
523+ format_dict_or_list (data ['TerroristInfo' ]['OcrResults' ], ['Keywords' ])
524+ format_dict (data ['TerroristInfo' ], ['OcrResults' , 'ObjectResults' ])
525+ if 'PoliticsInfo' in data :
526+ if 'OcrResults' in data ['PoliticsInfo' ]:
527+ format_dict_or_list (data ['PoliticsInfo' ]['OcrResults' ], ['Keywords' ])
528+ format_dict (data ['PoliticsInfo' ], ['OcrResults' , 'ObjectResults' ])
529+ if 'AdsInfo' in data :
530+ if 'OcrResults' in data ['AdsInfo' ]:
531+ format_dict_or_list (data ['AdsInfo' ]['OcrResults' ], ['Keywords' ])
532+ format_dict (data ['AdsInfo' ], ['OcrResults' , 'ObjectResults' ])
515533
516534 return data
517535
@@ -4434,7 +4452,7 @@ def ci_auditing_submit_common(self, Bucket, Key, DetectType, Type, Url=None, Biz
44344452
44354453 :param Bucket(string): 存储桶名称.
44364454 :param Key(string): COS路径.
4437- :param DetectType(int): 内容识别标志,位计算 1:porn, 2:terrorist, 4:politics, 8:ads
4455+ :param DetectType(int): 内容识别标志,位计算 1:porn, 2:terrorist, 4:politics, 8:ads, 16: Illegal, 32:Abuse
44384456 :param Type(string): 审核类型,video:视频,text:文本,audio:音频,docment:文档。
44394457 :param Url(string): Url, 支持非cos上的文件
44404458 :param Conf(dic): 审核的个性化配置
@@ -4505,6 +4523,7 @@ def ci_auditing_submit_common(self, Bucket, Key, DetectType, Type, Url=None, Biz
45054523 params = params ,
45064524 headers = headers )
45074525
4526+ logging .debug ("ci auditing rsp:%s" , rt .content )
45084527 data = xml_to_dict (rt .content )
45094528
45104529 return data
@@ -4557,6 +4576,7 @@ def ci_auditing_query_common(self, Bucket, Type, JobID, **kwargs):
45574576 params = params ,
45584577 headers = headers )
45594578
4579+ logging .debug ("query ci auditing:%s" , rt .content )
45604580 data = xml_to_dict (rt .content )
45614581
45624582 return data
@@ -4641,13 +4661,50 @@ def ci_auditing_video_query(self, Bucket, JobID, **kwargs):
46414661 print response
46424662 """
46434663
4644- return self .ci_auditing_query_common (
4664+ data = self .ci_auditing_query_common (
46454665 Bucket = Bucket ,
46464666 JobID = JobID ,
46474667 Type = 'video' ,
46484668 ** kwargs
46494669 )
46504670
4671+ if 'JobsDetail' in data :
4672+ format_dict (data ['JobsDetail' ], ['Snapshot' , 'AudioSection' ])
4673+ if 'Snapshot' in data ['JobsDetail' ]:
4674+ for snapshot in data ['JobsDetail' ]['Snapshot' ]:
4675+ if 'PornInfo' in snapshot :
4676+ format_dict (snapshot ['PornInfo' ], ['OcrResults' , 'ObjectResults' ])
4677+ if 'OcrResults' in snapshot ['PornInfo' ]:
4678+ for ocrResult in snapshot ['PornInfo' ]['OcrResults' ]:
4679+ format_dict (ocrResult , ['Keywords' ])
4680+ if 'TerrorismInfo' in snapshot :
4681+ format_dict (snapshot ['TerrorismInfo' ], ['OcrResults' , 'ObjectResults' ])
4682+ if 'OcrResults' in snapshot ['TerrorismInfo' ]:
4683+ for ocrResult in snapshot ['TerrorismInfo' ]['OcrResults' ]:
4684+ format_dict (ocrResult , ['Keywords' ])
4685+ if 'PoliticsInfo' in snapshot :
4686+ format_dict (snapshot ['PoliticsInfo' ], ['OcrResults' , 'ObjectResults' ])
4687+ if 'OcrResults' in snapshot ['PoliticsInfo' ]:
4688+ for ocrResult in snapshot ['PoliticsInfo' ]['OcrResults' ]:
4689+ format_dict (ocrResult , ['Keywords' ])
4690+ if 'AdsInfo' in snapshot :
4691+ format_dict (snapshot ['AdsInfo' ], ['OcrResults' , 'ObjectResults' ])
4692+ if 'OcrResults' in snapshot ['AdsInfo' ]:
4693+ for ocrResult in snapshot ['AdsInfo' ]['OcrResults' ]:
4694+ format_dict (ocrResult , ['Keywords' ])
4695+ if 'AudioSection' in data ['JobsDetail' ]:
4696+ for audioSection in data ['JobsDetail' ]['AudioSection' ]:
4697+ if 'PornInfo' in audioSection :
4698+ format_dict (audioSection ['PornInfo' ], ['Keywords' ])
4699+ if 'TerrorismInfo' in audioSection :
4700+ format_dict (audioSection ['TerrorismInfo' ], ['Keywords' ])
4701+ if 'PoliticsInfo' in audioSection :
4702+ format_dict (audioSection ['PoliticsInfo' ], ['Keywords' ])
4703+ if 'AdsInfo' in audioSection :
4704+ format_dict (audioSection ['AdsInfo' ], ['Keywords' ])
4705+
4706+ return data
4707+
46514708 def ci_auditing_audio_submit (self , Bucket , Key , DetectType , Url = None , Callback = None , CallbackVersion = 'Simple' , BizType = None , ** kwargs ):
46524709 """提交音频审核任务接口 https://cloud.tencent.com/document/product/460/53395
46534710
@@ -4714,12 +4771,26 @@ def ci_auditing_audio_query(self, Bucket, JobID, **kwargs):
47144771 print response
47154772 """
47164773
4717- return self .ci_auditing_query_common (
4774+ data = self .ci_auditing_query_common (
47184775 Bucket = Bucket ,
47194776 JobID = JobID ,
47204777 Type = 'audio' ,
47214778 ** kwargs
47224779 )
4780+ if 'JobsDetail' in data :
4781+ format_dict (data ['JobsDetail' ], ['Section' ])
4782+ if 'Section' in data ['JobsDetail' ]:
4783+ for section in data ['JobsDetail' ]['Section' ]:
4784+ if 'PornInfo' in section :
4785+ format_dict (section ['PornInfo' ], ['Keywords' ])
4786+ if 'TerrorismInfo' in section :
4787+ format_dict (section ['TerrorismInfo' ], ['Keywords' ])
4788+ if 'PoliticsInfo' in section :
4789+ format_dict (section ['PoliticsInfo' ], ['Keywords' ])
4790+ if 'AdsInfo' in section :
4791+ format_dict (section ['AdsInfo' ], ['Keywords' ])
4792+
4793+ return data
47234794
47244795 def ci_auditing_text_submit (self , Bucket , Key , DetectType , Content = None , Callback = None , BizType = None , ** kwargs ):
47254796 """提交文本审核任务接口 https://cloud.tencent.com/document/product/460/56285
@@ -4758,7 +4829,7 @@ def ci_auditing_text_submit(self, Bucket, Key, DetectType, Content=None, Callbac
47584829 if Callback :
47594830 conf ['Callback' ] = Callback
47604831
4761- return self .ci_auditing_submit_common (
4832+ data = self .ci_auditing_submit_common (
47624833 Bucket = Bucket ,
47634834 Key = Key ,
47644835 Type = 'text' ,
@@ -4769,6 +4840,11 @@ def ci_auditing_text_submit(self, Bucket, Key, DetectType, Content=None, Callbac
47694840 ** kwargs
47704841 )
47714842
4843+ if 'JobsDetail' in data :
4844+ format_dict (data ['JobsDetail' ], ['Section' ])
4845+
4846+ return data
4847+
47724848 def ci_auditing_text_query (self , Bucket , JobID , ** kwargs ):
47734849 """查询文本审核任务接口 https://cloud.tencent.com/document/product/460/56284
47744850
@@ -4789,19 +4865,23 @@ def ci_auditing_text_query(self, Bucket, JobID, **kwargs):
47894865 print response
47904866 """
47914867
4792- return self .ci_auditing_query_common (
4868+ data = self .ci_auditing_query_common (
47934869 Bucket = Bucket ,
47944870 JobID = JobID ,
47954871 Type = 'text' ,
47964872 ** kwargs
47974873 )
4874+ if 'JobsDetail' in data :
4875+ format_dict (data ['JobsDetail' ], ['Section' ])
4876+ return data
47984877
4799- def ci_auditing_document_submit (self , Bucket , Url , DetectType , Type = None , Callback = None , BizType = None , ** kwargs ):
4878+ def ci_auditing_document_submit (self , Bucket , Url , DetectType , Key = None , Type = None , Callback = None , BizType = None , ** kwargs ):
48004879 """提交文档审核任务接口 https://cloud.tencent.com/document/product/460/59380
48014880
48024881 :param Bucket(string): 存储桶名称.
48034882 :param Url(string): 文档文件的链接地址,例如 http://www.example.com/doctest.doc
48044883 :param DetectType(int): 内容识别标志,位计算 1:porn, 2:terrorist, 4:politics, 8:ads
4884+ :param Key(string): 存储在 COS 存储桶中的文件名称,例如在目录 test 中的文件test.doc,则文件名称为 test/test. Key 和 Url 只能选择其中一种。
48054885 :param Type(string): 指定文档文件的类型,如未指定则默认以文件的后缀为类型。
48064886 如果文件没有后缀,该字段必须指定,否则会审核失败。例如:doc、docx、ppt、pptx 等
48074887 :param Callback(string): 回调地址,以http://或者https://开头的地址。
@@ -4822,7 +4902,11 @@ def ci_auditing_document_submit(self, Bucket, Url, DetectType, Type=None, Callba
48224902 print response
48234903 """
48244904
4825- Input = {'Url' : Url }
4905+ Input = {}
4906+ if Url is not None :
4907+ Input ['Url' ] = Url
4908+ if Key is not None :
4909+ Input ['Object' ] = Key
48264910 if Type :
48274911 Input ['Type' ] = Type
48284912
@@ -4863,13 +4947,35 @@ def ci_auditing_document_query(self, Bucket, JobID, **kwargs):
48634947 print response
48644948 """
48654949
4866- return self .ci_auditing_query_common (
4950+ data = self .ci_auditing_query_common (
48674951 Bucket = Bucket ,
48684952 JobID = JobID ,
48694953 Type = 'document' ,
48704954 ** kwargs
48714955 )
48724956
4957+ if 'JobsDetail' in data and 'PageSegment' in data ['JobsDetail' ] and 'Results' in data ['JobsDetail' ]['PageSegment' ]:
4958+ format_dict (data ['JobsDetail' ]['PageSegment' ], ['Results' ])
4959+ for resultsItem in data ['JobsDetail' ]['PageSegment' ]['Results' ]:
4960+ if 'PornInfo' in resultsItem :
4961+ format_dict (resultsItem ['PornInfo' ], ['OcrResults' , 'ObjectResults' ])
4962+ if 'OcrResults' in resultsItem ['PornInfo' ]:
4963+ format_dict_or_list (resultsItem ['PornInfo' ]['OcrResults' ], ['Keywords' ])
4964+ if 'TerrorismInfo' in resultsItem :
4965+ format_dict (resultsItem ['TerrorismInfo' ], ['OcrResults' , 'ObjectResults' ])
4966+ if 'OcrResults' in resultsItem ['TerrorismInfo' ]:
4967+ format_dict_or_list (resultsItem ['TerrorismInfo' ]['OcrResults' ], ['Keywords' ])
4968+ if 'PoliticsInfo' in resultsItem :
4969+ format_dict (resultsItem ['PoliticsInfo' ], ['OcrResults' , 'ObjectResults' ])
4970+ if 'OcrResults' in resultsItem ['PoliticsInfo' ]:
4971+ format_dict_or_list (resultsItem ['PoliticsInfo' ]['OcrResults' ], ['Keywords' ])
4972+ if 'AdsInfo' in resultsItem :
4973+ format_dict (resultsItem ['AdsInfo' ], ['OcrResults' , 'ObjectResults' ])
4974+ if 'OcrResults' in resultsItem ['AdsInfo' ]:
4975+ format_dict_or_list (resultsItem ['AdsInfo' ]['OcrResults' ], ['Keywords' ])
4976+
4977+ return data
4978+
48734979 def ci_get_media_queue (self , Bucket , ** kwargs ):
48744980 """查询媒体处理队列接口 https://cloud.tencent.com/document/product/436/54045
48754981
0 commit comments