-
Notifications
You must be signed in to change notification settings - Fork 91
/
ci.go
2790 lines (2517 loc) · 96.9 KB
/
ci.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package cos
import (
"bytes"
"context"
"encoding/base64"
"encoding/json"
"encoding/xml"
"errors"
"fmt"
"hash/crc64"
"io"
"net/http"
"net/url"
"os"
"strconv"
)
type CIService service
type PicOperations struct {
IsPicInfo int `json:"is_pic_info,omitempty"`
Rules []PicOperationsRules `json:"rules,omitemtpy"`
}
type PicOperationsRules struct {
Bucket string `json:"bucket,omitempty"`
FileId string `json:"fileid"`
Rule string `json:"rule"`
}
func EncodePicOperations(pic *PicOperations) string {
if pic == nil {
return ""
}
bs, err := json.Marshal(pic)
if err != nil {
return ""
}
return string(bs)
}
type ImageProcessResult struct {
XMLName xml.Name `xml:"UploadResult"`
OriginalInfo *PicOriginalInfo `xml:"OriginalInfo,omitempty"`
ProcessResults []PicProcessObject `xml:"ProcessResults>Object,omitempty"`
// 历史兼容考虑不建议抽象单独struct防止客户使用影响
ProcessResultsText string `xml:"ProcessResults>Text,omitempty"`
ProcessResultsWatermarkStatusCode int `xml:"ProcessResults>WatermarkStatusCode,omitempty"`
}
type PicOriginalInfo struct {
Key string `xml:"Key,omitempty"`
Location string `xml:"Location,omitempty"`
ImageInfo *PicImageInfo `xml:"ImageInfo,omitempty"`
ETag string `xml:"ETag,omitempty"`
}
type PicImageInfo struct {
Format string `xml:"Format,omitempty"`
Width int `xml:"Width,omitempty"`
Height int `xml:"Height,omitempty"`
Quality int `xml:"Quality,omitempty"`
Ave string `xml:"Ave,omitempty"`
Orientation int `xml:"Orientation,omitempty"`
}
type PicProcessObject struct {
Key string `xml:"Key,omitempty"`
Location string `xml:"Location,omitempty"`
Format string `xml:"Format,omitempty"`
Width int `xml:"Width,omitempty"`
Height int `xml:"Height,omitempty"`
Size int `xml:"Size,omitempty"`
Quality int `xml:"Quality,omitempty"`
ETag string `xml:"ETag,omitempty"`
WatermarkStatus int `xml:"WatermarkStatus,omitempty"`
CodeStatus int `xml:"CodeStatus,omitempty"`
QRcodeInfo []QRcodeInfo `xml:"QRcodeInfo,omitempty"`
}
type QRcodeInfo struct {
CodeUrl string `xml:"CodeUrl,omitempty"`
CodeLocation *CodeLocation `xml:"CodeLocation,omitempty"`
}
type CodeLocation struct {
Point []string `xml:"Point,omitempty"`
}
type picOperationsHeader struct {
PicOperations string `header:"Pic-Operations" xml:"-" url:"-"`
}
type ImageProcessOptions = PicOperations
// 云上数据处理 https://cloud.tencent.com/document/product/460/18147
func (s *CIService) ImageProcess(ctx context.Context, name string, opt *ImageProcessOptions) (*ImageProcessResult, *Response, error) {
header := &picOperationsHeader{
PicOperations: EncodePicOperations(opt),
}
var res ImageProcessResult
sendOpt := sendOptions{
baseURL: s.client.BaseURL.BucketURL,
uri: "/" + encodeURIComponent(name) + "?image_process",
method: http.MethodPost,
optHeader: header,
result: &res,
}
resp, err := s.client.send(ctx, &sendOpt)
return &res, resp, err
}
// ImageRecognitionOptions is the option of ImageAuditing
type ImageRecognitionOptions struct {
CIProcess string `url:"ci-process,omitempty"`
DetectType string `url:"detect-type,omitempty"`
DetectUrl string `url:"detect-url,omitempty"`
Interval int `url:"interval,omitempty"`
MaxFrames int `url:"max-frames,omitempty"`
BizType string `url:"biz-type,omitempty"`
LargeImageDetect int `url:"large-image-detect,omitempty"`
DataId string `url:"dataid,omitempty"`
Async int `url:"async,omitempty"`
Callback string `url:"callback,omitempty"`
}
type UserListInfo struct {
ListResults []UserListResults `xml:",omitempty"`
}
// AuditingMaskInfo 审核马赛克信息
type AuditingMaskInfo struct {
RecordInfo *AuditingMaskRecordInfo `xml:",omitempty"`
LiveInfo *AuditingMaskLiveInfo `xml:",omitempty"`
}
// AuditingMaskInfo 审核马赛克信息
type AuditingMaskRecordInfo struct {
Code string `xml:"Code,omitempty"`
Message string `xml:"Message,omitempty"`
Output *struct {
Region string `xml:"Region,omitempty"`
Bucket string `xml:"Bucket,omitempty"`
Object string `xml:"Object,omitempty"`
} `xml:"Output,omitempty"`
}
// AuditingMaskInfo 审核马赛克信息
type AuditingMaskLiveInfo struct {
StartTime string `xml:"StartTime,omitempty"`
EndTime string `xml:"EndTime,omitempty"`
Output string `xml:"Output,omitempty"`
}
// UserListResults 命中账号黑白名单信息
type UserListResults struct {
ListType *int `xml:",omitempty"`
ListName string `xml:",omitempty"`
Entity string `xml:",omitempty"`
}
// ImageRecognitionResult is the result of ImageRecognition/ImageAuditing
type ImageRecognitionResult struct {
XMLName xml.Name `xml:"RecognitionResult"`
JobId string `xml:"JobId,omitempty"`
State string `xml:"State,omitempty"`
Object string `xml:"Object,omitempty"`
Url string `xml:"Url,omitempty"`
Text string `xml:"Text,omitempty"`
Label string `xml:"Label,omitempty"`
Result int `xml:"Result,omitempty"`
Score int `xml:"Score,omitempty"`
Category string `xml:"Category,omitempty"`
SubLabel string `xml:"SubLabel,omitempty"`
PornInfo *RecognitionInfo `xml:"PornInfo,omitempty"`
TerroristInfo *RecognitionInfo `xml:"TerroristInfo,omitempty"`
PoliticsInfo *RecognitionInfo `xml:"PoliticsInfo,omitempty"`
AdsInfo *RecognitionInfo `xml:"AdsInfo,omitempty"`
TeenagerInfo *RecognitionInfo `xml:"TeenagerInfo,omitempty"`
TerrorismInfo *RecognitionInfo `xml:"TerrorismInfo,omitempty"`
CompressionResult int `xml:"CompressionResult,omitempty"`
DataId string `xml:"DataId,omitempty"`
}
// RecognitionInfo is the result of auditing scene
type RecognitionInfo struct {
Code int `xml:"Code,omitempty"`
Msg string `xml:"Msg,omitempty"`
HitFlag int `xml:"HitFlag,omitempty"`
Score int `xml:"Score,omitempty"`
Label string `xml:"Label,omitempty"`
Count int `xml:"Count,omitempty"`
Category string `xml:"Category,omitempty"`
SubLabel string `xml:"SubLabel,omitempty"`
Keywords []string `xml:"Keywords,omitempty"`
OcrResults []OcrResult `xml:"OcrResults,omitempty"`
ObjectResults []ObjectResult `xml:"ObjectResults,omitempty"`
LibResults []LibResult `xml:"LibResults,omitempty"`
SpeakerResults []LanguageResult `xml:"SpeakerResults,omitempty"`
RecognitionResults []LanguageResult `xml:"RecognitionResults,omitempty"`
}
// 图片审核 https://cloud.tencent.com/document/product/460/37318
func (s *CIService) ImageRecognition(ctx context.Context, name string, reserved string) (*ImageRecognitionResult, *Response, error) {
opt := &ImageRecognitionOptions{
CIProcess: "sensitive-content-recognition",
}
var res ImageRecognitionResult
sendOpt := sendOptions{
baseURL: s.client.BaseURL.BucketURL,
uri: "/" + encodeURIComponent(name),
method: http.MethodGet,
optQuery: opt,
result: &res,
}
resp, err := s.client.send(ctx, &sendOpt)
return &res, resp, err
}
// 图片审核 支持detect-url等全部参数
func (s *CIService) ImageAuditing(ctx context.Context, name string, opt *ImageRecognitionOptions) (*ImageRecognitionResult, *Response, error) {
var res ImageRecognitionResult
sendOpt := sendOptions{
baseURL: s.client.BaseURL.BucketURL,
uri: "/" + encodeURIComponent(name),
method: http.MethodGet,
optQuery: opt,
result: &res,
}
resp, err := s.client.send(ctx, &sendOpt)
return &res, resp, err
}
// UserExtraInfo is user defined information
type UserExtraInfo struct {
TokenId string `xml:",omitempty"`
Nickname string `xml:",omitempty"`
DeviceId string `xml:",omitempty"`
AppId string `xml:",omitempty"`
Room string `xml:",omitempty"`
IP string `xml:",omitempty"`
Type string `xml:",omitempty"`
ReceiveTokenId string `xml:",omitempty"`
Gender string `xml:",omitempty"`
Level string `xml:",omitempty"`
Role string `xml:",omitempty"`
}
// Encryption is user defined information
type Encryption struct {
Algorithm string `xml:",omitempty"`
Key string `xml:",omitempty"`
IV string `xml:",omitempty"`
KeyId string `xml:",omitempty"`
KeyType int `xml:",omitempty"`
}
// FreezeConf is auto freeze options
type FreezeConf struct {
PornScore string `xml:",omitempty"`
IllegalScore string `xml:",omitempty"`
TerrorismScore string `xml:",omitempty"`
PoliticsScore string `xml:",omitempty"`
AdsScore string `xml:",omitempty"`
AbuseScore string `xml:",omitempty"`
TeenagerScore string `xml:",omitempty"`
}
// AuditingMask is auto Mask options
type AuditingMask struct {
Images []AuditingMaskImages `xml:",omitempty"`
Audios []AuditingMaskAudios `xml:",omitempty"`
CosOutput *AuditingMaskCosOutput `xml:",omitempty"`
LiveOutput *AuditingMaskLiveOutput `xml:",omitempty"`
}
// AuditingMaskImages 审核马赛克相关参数
type AuditingMaskImages struct {
Label string `xml:",omitempty"`
Type string `xml:",omitempty"`
Url string `xml:",omitempty"`
}
// AuditingMaskAudios 审核马赛克相关参数
type AuditingMaskAudios struct {
Label string `xml:",omitempty"`
Type string `xml:",omitempty"`
}
// AuditingMaskCosOutput 审核马赛克相关参数
type AuditingMaskCosOutput struct {
Region string `xml:"Region,omitempty"`
Bucket string `xml:"Bucket,omitempty"`
Object string `xml:"Object,omitempty"`
Transcode *Transcode `xml:",omitempty"`
}
// AuditingMaskLiveOutput 审核马赛克相关参数
type AuditingMaskLiveOutput struct {
Url string `xml:"Url,omitempty"`
Transcode *Transcode `xml:",omitempty"`
}
// ImageAuditingInputOptions is the option of BatchImageAuditingOptions
type ImageAuditingInputOptions struct {
DataId string `xml:",omitempty"`
Object string `xml:",omitempty"`
Url string `xml:",omitempty"`
Content string `xml:",omitempty"`
Interval int `xml:",omitempty"`
MaxFrames int `xml:",omitempty"`
LargeImageDetect int `xml:",omitempty"`
UserInfo *UserExtraInfo `xml:",omitempty"`
}
// ImageAuditingJobConf is the config of BatchImageAuditingOptions
type ImageAuditingJobConf struct {
DetectType string `xml:",omitempty"`
BizType string `xml:",omitempty"`
Async int `xml:",omitempty"`
Callback string `xml:",omitempty"`
Freeze *FreezeConf `xml:",omitempty"`
}
// BatchImageAuditingOptions is the option of BatchImageAuditing
type BatchImageAuditingOptions struct {
XMLName xml.Name `xml:"Request"`
Input []ImageAuditingInputOptions `xml:"Input,omitempty"`
Conf *ImageAuditingJobConf `xml:"Conf"`
}
// ImageAuditingResult is the result of BatchImageAuditingJobResult
type ImageAuditingResult struct {
Code string `xml:",omitempty"`
Message string `xml:",omitempty"`
JobId string `xml:",omitempty"`
State string `xml:",omitempty"`
DataId string `xml:",omitempty"`
Object string `xml:",omitempty"`
Url string `xml:",omitempty"`
Text string `xml:",omitempty"`
Label string `xml:",omitempty"`
Result int `xml:",omitempty"`
Score int `xml:",omitempty"`
Category string `xml:",omitempty"`
SubLabel string `xml:",omitempty"`
PornInfo *RecognitionInfo `xml:",omitempty"`
TerrorismInfo *RecognitionInfo `xml:",omitempty"`
PoliticsInfo *RecognitionInfo `xml:",omitempty"`
AdsInfo *RecognitionInfo `xml:",omitempty"`
TeenagerInfo *RecognitionInfo `xml:",omitempty"`
CompressionResult int `xml:",omitempty"`
UserInfo *UserExtraInfo `xml:",omitempty"`
Encryption *Encryption `xml:",omitempty"`
ListInfo *UserListInfo `xml:",omitempty"`
ForbidState int `xml:",omitempty"`
}
// BatchImageAuditingJobResult is the result of BatchImageAuditing
type BatchImageAuditingJobResult struct {
XMLName xml.Name `xml:"Response"`
JobsDetail []ImageAuditingResult `xml:",omitempty"`
RequestId string `xml:",omitempty"`
}
// 图片批量审核接口
func (s *CIService) BatchImageAuditing(ctx context.Context, opt *BatchImageAuditingOptions) (*BatchImageAuditingJobResult, *Response, error) {
var res BatchImageAuditingJobResult
sendOpt := sendOptions{
baseURL: s.client.BaseURL.CIURL,
uri: "/image/auditing",
method: http.MethodPost,
body: opt,
result: &res,
}
resp, err := s.client.send(ctx, &sendOpt)
return &res, resp, err
}
// GetImageAuditingJobResult is the result of GetImageAuditingJob
type GetImageAuditingJobResult struct {
XMLName xml.Name `xml:"Response"`
JobsDetail *ImageAuditingResult `xml:",omitempty"`
RequestId string `xml:",omitempty"`
}
// 图片审核-查询任务
func (s *CIService) GetImageAuditingJob(ctx context.Context, jobid string) (*GetImageAuditingJobResult, *Response, error) {
var res GetImageAuditingJobResult
sendOpt := sendOptions{
baseURL: s.client.BaseURL.CIURL,
uri: "/image/auditing/" + jobid,
method: http.MethodGet,
result: &res,
}
resp, err := s.client.send(ctx, &sendOpt)
return &res, resp, err
}
// PutVideoAuditingJobOptions is the option of PutVideoAuditingJob
type PutVideoAuditingJobOptions struct {
XMLName xml.Name `xml:"Request"`
InputObject string `xml:"Input>Object,omitempty"`
InputUrl string `xml:"Input>Url,omitempty"`
InputDataId string `xml:"Input>DataId,omitempty"`
InputUserInfo *UserExtraInfo `xml:"Input>UserInfo,omitempty"`
Encryption *Encryption `xml:",omitempty"`
Conf *VideoAuditingJobConf `xml:"Conf"`
Type string `xml:"Type,omitempty"`
StorageConf *StorageConf `xml:"StorageConf,omitempty"`
}
// VideoAuditingJobConf is the config of PutVideoAuditingJobOptions
type VideoAuditingJobConf struct {
DetectType string `xml:",omitempty"`
Snapshot *PutVideoAuditingJobSnapshot `xml:",omitempty"`
Callback string `xml:",omitempty"`
CallbackVersion string `xml:",omitempty"`
CallbackType int `xml:",omitempty"`
BizType string `xml:",omitempty"`
DetectContent int `xml:",omitempty"`
Freeze *FreezeConf `xml:",omitempty"`
Mask *AuditingMask `xml:",omitempty"`
}
// PutVideoAuditingJobSnapshot is the snapshot config of VideoAuditingJobConf
type PutVideoAuditingJobSnapshot struct {
Mode string `xml:",omitempty"`
Count int `xml:",omitempty"`
TimeInterval float32 `xml:",omitempty"`
}
// StorageConf is live video storage config of PutVideoAuditingJobOptions
type StorageConf struct {
Path string `xml:",omitempty"`
}
// PutVideoAuditingJobResult is the result of PutVideoAuditingJob
type PutVideoAuditingJobResult struct {
XMLName xml.Name `xml:"Response"`
JobsDetail struct {
JobId string `xml:"JobId,omitempty"`
State string `xml:"State,omitempty"`
CreationTime string `xml:"CreationTime,omitempty"`
Object string `xml:"Object,omitempty"`
Url string `xml:"Url,omitempty"`
} `xml:"JobsDetail,omitempty"`
RequestId string `xml:"RequestId,omitempty"`
}
// 视频审核-创建任务 https://cloud.tencent.com/document/product/460/46427
func (s *CIService) PutVideoAuditingJob(ctx context.Context, opt *PutVideoAuditingJobOptions) (*PutVideoAuditingJobResult, *Response, error) {
var res PutVideoAuditingJobResult
sendOpt := sendOptions{
baseURL: s.client.BaseURL.CIURL,
uri: "/video/auditing",
method: http.MethodPost,
body: opt,
result: &res,
}
resp, err := s.client.send(ctx, &sendOpt)
return &res, resp, err
}
// GetVideoAuditingJobResult is the result of GetVideoAuditingJob
type GetVideoAuditingJobResult struct {
XMLName xml.Name `xml:"Response"`
JobsDetail *AuditingJobDetail `xml:",omitempty"`
RequestId string `xml:",omitempty"`
}
// AuditingJobDetail is the detail of GetVideoAuditingJobResult
type AuditingJobDetail struct {
Code string `xml:",omitempty"`
Message string `xml:",omitempty"`
JobId string `xml:",omitempty"`
State string `xml:",omitempty"`
CreationTime string `xml:",omitempty"`
Object string `xml:",omitempty"`
Url string `xml:",omitempty"`
DataId string `xml:",omitempty"`
SnapshotCount string `xml:",omitempty"`
Label string `xml:",omitempty"`
SubLabel string `xml:",omitempty"`
Result int `xml:",omitempty"`
PornInfo *RecognitionInfo `xml:",omitempty"`
TerrorismInfo *RecognitionInfo `xml:",omitempty"`
PoliticsInfo *RecognitionInfo `xml:",omitempty"`
AdsInfo *RecognitionInfo `xml:",omitempty"`
TeenagerInfo *RecognitionInfo `xml:",omitempty"`
Snapshot []GetVideoAuditingJobSnapshot `xml:",omitempty"`
AudioSection []AudioSectionResult `xml:",omitempty"`
UserInfo *UserExtraInfo `xml:",omitempty"`
Type string `xml:",omitempty"`
ListInfo *UserListInfo `xml:",omitempty"`
ForbidState int `xml:",omitempty"`
MaskInfo *AuditingMaskInfo `xml:",omitempty"`
}
// GetVideoAuditingJobSnapshot is the snapshot result of AuditingJobDetail
type GetVideoAuditingJobSnapshot struct {
Url string `xml:",omitempty"`
Text string `xml:",omitempty"`
SnapshotTime int `xml:",omitempty"`
Label string `xml:",omitempty"`
Result int `xml:",omitempty"`
PornInfo *RecognitionInfo `xml:",omitempty"`
TerrorismInfo *RecognitionInfo `xml:",omitempty"`
PoliticsInfo *RecognitionInfo `xml:",omitempty"`
AdsInfo *RecognitionInfo `xml:",omitempty"`
TeenagerInfo *RecognitionInfo `xml:",omitempty"`
}
// AudioSectionResult is the audio section result of AuditingJobDetail/AudioAuditingJobDetail
type AudioSectionResult struct {
Url string `xml:",omitempty"`
Text string `xml:",omitempty"`
OffsetTime int `xml:",omitempty"`
Duration int `xml:",omitempty"`
Label string `xml:",omitempty"`
SubLabel string `xml:",omitempty"`
Result int `xml:",omitempty"`
PornInfo *RecognitionInfo `xml:",omitempty"`
TerrorismInfo *RecognitionInfo `xml:",omitempty"`
PoliticsInfo *RecognitionInfo `xml:",omitempty"`
AdsInfo *RecognitionInfo `xml:",omitempty"`
TeenagerInfo *RecognitionInfo `xml:",omitempty"`
LanguageResults []LanguageResult `xml:",omitempty"`
}
// 视频审核-查询任务 https://cloud.tencent.com/document/product/460/46926
func (s *CIService) GetVideoAuditingJob(ctx context.Context, jobid string) (*GetVideoAuditingJobResult, *Response, error) {
var res GetVideoAuditingJobResult
sendOpt := sendOptions{
baseURL: s.client.BaseURL.CIURL,
uri: "/video/auditing/" + jobid,
method: http.MethodGet,
result: &res,
}
resp, err := s.client.send(ctx, &sendOpt)
return &res, resp, err
}
// 视频审核-取消直播流审核任务
func (s *CIService) PostVideoAuditingCancelJob(ctx context.Context, jobid string) (*PutVideoAuditingJobResult, *Response, error) {
var res PutVideoAuditingJobResult
sendOpt := sendOptions{
baseURL: s.client.BaseURL.CIURL,
uri: "/video/cancel_auditing/" + jobid,
method: http.MethodPost,
result: &res,
}
resp, err := s.client.send(ctx, &sendOpt)
return &res, resp, err
}
// PutAudioAuditingJobOptions is the option of PutAudioAuditingJob
type PutAudioAuditingJobOptions struct {
XMLName xml.Name `xml:"Request"`
InputObject string `xml:"Input>Object,omitempty"`
InputUrl string `xml:"Input>Url,omitempty"`
InputDataId string `xml:"Input>DataId,omitempty"`
InputUserInfo *UserExtraInfo `xml:"Input>UserInfo,omitempty"`
Conf *AudioAuditingJobConf `xml:"Conf"`
}
// AudioAuditingJobConf is the config of PutAudioAuditingJobOptions
type AudioAuditingJobConf struct {
DetectType string `xml:",omitempty"`
Callback string `xml:",omitempty"`
CallbackVersion string `xml:",omitempty"`
CallbackType int `xml:",omitempty"`
BizType string `xml:",omitempty"`
Freeze *FreezeConf `xml:",omitempty"`
}
// PutAudioAuditingJobResult is the result of PutAudioAuditingJob
type PutAudioAuditingJobResult PutVideoAuditingJobResult
// 音频审核-创建任务 https://cloud.tencent.com/document/product/460/53395
func (s *CIService) PutAudioAuditingJob(ctx context.Context, opt *PutAudioAuditingJobOptions) (*PutAudioAuditingJobResult, *Response, error) {
var res PutAudioAuditingJobResult
sendOpt := sendOptions{
baseURL: s.client.BaseURL.CIURL,
uri: "/audio/auditing",
method: http.MethodPost,
body: opt,
result: &res,
}
resp, err := s.client.send(ctx, &sendOpt)
return &res, resp, err
}
// GetAudioAuditingJobResult is the result of GetAudioAuditingJob
type GetAudioAuditingJobResult struct {
XMLName xml.Name `xml:"Response"`
JobsDetail *AudioAuditingJobDetail `xml:",omitempty"`
RequestId string `xml:",omitempty"`
}
// AudioAuditingJobDetail is the detail of GetAudioAuditingJobResult
type AudioAuditingJobDetail struct {
Code string `xml:",omitempty"`
Message string `xml:",omitempty"`
JobId string `xml:",omitempty"`
State string `xml:",omitempty"`
CreationTime string `xml:",omitempty"`
Object string `xml:",omitempty"`
Url string `xml:",omitempty"`
DataId string `xml:",omitempty"`
AudioText string `xml:",omitempty"`
Label string `xml:",omitempty"`
Result int `xml:",omitempty"`
PornInfo *RecognitionInfo `xml:",omitempty"`
TerrorismInfo *RecognitionInfo `xml:",omitempty"`
PoliticsInfo *RecognitionInfo `xml:",omitempty"`
AdsInfo *RecognitionInfo `xml:",omitempty"`
TeenagerInfo *RecognitionInfo `xml:",omitempty"`
LanguageResults []LanguageResult `xml:",omitempty"`
Section []AudioSectionResult `xml:",omitempty"`
UserInfo *UserExtraInfo `xml:",omitempty"`
ListInfo *UserListInfo `xml:",omitempty"`
ForbidState int `xml:",omitempty"`
}
// LanguageResult 语种识别结果
type LanguageResult struct {
Label string `xml:"Label"`
Score uint32 `xml:"Score"`
StartTime *int64 `xml:"StartTime,omitempty"`
EndTime *int64 `xml:"EndTime,omitempty"`
}
// 音频审核-查询任务 https://cloud.tencent.com/document/product/460/53396
func (s *CIService) GetAudioAuditingJob(ctx context.Context, jobid string) (*GetAudioAuditingJobResult, *Response, error) {
var res GetAudioAuditingJobResult
sendOpt := sendOptions{
baseURL: s.client.BaseURL.CIURL,
uri: "/audio/auditing/" + jobid,
method: http.MethodGet,
result: &res,
}
resp, err := s.client.send(ctx, &sendOpt)
return &res, resp, err
}
// PutTextAuditingJobOptions is the option of PutTextAuditingJob
type PutTextAuditingJobOptions struct {
XMLName xml.Name `xml:"Request"`
InputObject string `xml:"Input>Object,omitempty"`
InputUrl string `xml:"Input>Url,omitempty"`
InputContent string `xml:"Input>Content,omitempty"`
InputDataId string `xml:"Input>DataId,omitempty"`
InputUserInfo *UserExtraInfo `xml:"Input>UserInfo,omitempty"`
Conf *TextAuditingJobConf `xml:"Conf"`
}
// TextAuditingJobConf is the config of PutAudioAuditingJobOptions
type TextAuditingJobConf struct {
DetectType string `xml:",omitempty"`
Callback string `xml:",omitempty"`
CallbackVersion string `xml:",omitempty"`
BizType string `xml:",omitempty"`
CallbackType int `xml:",omitempty"`
Freeze *FreezeConf `xml:",omitempty"`
}
// PutTextAuditingJobResult is the result of PutTextAuditingJob
type PutTextAuditingJobResult GetTextAuditingJobResult
// 文本审核-创建任务 https://cloud.tencent.com/document/product/436/56289
func (s *CIService) PutTextAuditingJob(ctx context.Context, opt *PutTextAuditingJobOptions) (*PutTextAuditingJobResult, *Response, error) {
var res PutTextAuditingJobResult
sendOpt := sendOptions{
baseURL: s.client.BaseURL.CIURL,
uri: "/text/auditing",
method: http.MethodPost,
body: opt,
result: &res,
}
resp, err := s.client.send(ctx, &sendOpt)
return &res, resp, err
}
// GetTextAuditingJobResult is the result of GetTextAuditingJob
type GetTextAuditingJobResult struct {
XMLName xml.Name `xml:"Response"`
JobsDetail *TextAuditingJobDetail `xml:",omitempty"`
RequestId string `xml:",omitempty"`
}
// TextAuditingJobDetail is the detail of GetTextAuditingJobResult
type TextAuditingJobDetail struct {
Code string `xml:",omitempty"`
Message string `xml:",omitempty"`
JobId string `xml:",omitempty"`
State string `xml:",omitempty"`
CreationTime string `xml:",omitempty"`
Object string `xml:",omitempty"`
Url string `xml:",omitempty"`
DataId string `xml:",omitempty"`
Content string `xml:",omitempty"`
SectionCount int `xml:",omitempty"`
Label string `xml:",omitempty"`
Result int `xml:",omitempty"`
PornInfo *TextRecognitionInfo `xml:",omitempty"`
TerrorismInfo *TextRecognitionInfo `xml:",omitempty"`
PoliticsInfo *TextRecognitionInfo `xml:",omitempty"`
AdsInfo *TextRecognitionInfo `xml:",omitempty"`
IllegalInfo *TextRecognitionInfo `xml:",omitempty"`
AbuseInfo *TextRecognitionInfo `xml:",omitempty"`
Section []TextSectionResult `xml:",omitempty"`
UserInfo *UserExtraInfo `xml:",omitempty"`
ListInfo *UserListInfo `xml:",omitempty"`
ForbidState int `xml:",omitempty"`
ValueInfo *TextRecognitionInfo `xml:",omitempty"`
SpamInfo *TextRecognitionInfo `xml:",omitempty"`
}
// TextLibResult
type TextLibResult struct {
LibType int32 `xml:"LibType,omitempty"`
LibName string `xml:"LibName,omitempty"`
Keywords []string `xml:"Keywords,omitempty"`
}
// TextRecognitionInfo
type TextRecognitionInfo struct {
Code int `xml:",omitempty"`
HitFlag int `xml:",omitempty"`
Score int `xml:",omitempty"`
Count int `xml:",omitempty"`
Keywords string `xml:",omitempty"`
LibResults []TextLibResult `xml:",omitempty"`
SubLabel string `xml:",omitempty"`
}
// TextSectionResult is the section result of TextAuditingJobDetail
type TextSectionResult struct {
StartByte int `xml:",omitempty"`
Label string `xml:",omitempty"`
Result int `xml:",omitempty"`
PornInfo *TextRecognitionInfo `xml:",omitempty"`
TerrorismInfo *TextRecognitionInfo `xml:",omitempty"`
PoliticsInfo *TextRecognitionInfo `xml:",omitempty"`
AdsInfo *TextRecognitionInfo `xml:",omitempty"`
IllegalInfo *TextRecognitionInfo `xml:",omitempty"`
AbuseInfo *TextRecognitionInfo `xml:",omitempty"`
ValueInfo *TextRecognitionInfo `xml:",omitempty"`
SpamInfo *TextRecognitionInfo `xml:",omitempty"`
}
// 文本审核-查询任务 https://cloud.tencent.com/document/product/436/56288
func (s *CIService) GetTextAuditingJob(ctx context.Context, jobid string) (*GetTextAuditingJobResult, *Response, error) {
var res GetTextAuditingJobResult
sendOpt := sendOptions{
baseURL: s.client.BaseURL.CIURL,
uri: "/text/auditing/" + jobid,
method: http.MethodGet,
result: &res,
}
resp, err := s.client.send(ctx, &sendOpt)
return &res, resp, err
}
// PutDocumentAuditingJobOptions is the option of PutDocumentAuditingJob
type PutDocumentAuditingJobOptions struct {
XMLName xml.Name `xml:"Request"`
InputObject string `xml:"Input>Object,omitempty"`
InputUrl string `xml:"Input>Url,omitempty"`
InputType string `xml:"Input>Type,omitempty"`
InputDataId string `xml:"Input>DataId,omitempty"`
InputUserInfo *UserExtraInfo `xml:"Input>UserInfo,omitempty"`
Conf *DocumentAuditingJobConf `xml:"Conf"`
}
// DocumentAuditingJobConf is the config of PutDocumentAuditingJobOptions
type DocumentAuditingJobConf struct {
DetectType string `xml:",omitempty"`
Callback string `xml:",omitempty"`
BizType string `xml:",omitempty"`
CallbackType int `xml:",omitempty"`
Freeze *FreezeConf `xml:",omitempty"`
}
// PutDocumentAuditingJobResult is the result of PutDocumentAuditingJob
type PutDocumentAuditingJobResult PutVideoAuditingJobResult
// 文档审核-创建任务 https://cloud.tencent.com/document/product/436/59381
func (s *CIService) PutDocumentAuditingJob(ctx context.Context, opt *PutDocumentAuditingJobOptions) (*PutDocumentAuditingJobResult, *Response, error) {
var res PutDocumentAuditingJobResult
sendOpt := sendOptions{
baseURL: s.client.BaseURL.CIURL,
uri: "/document/auditing",
method: http.MethodPost,
body: opt,
result: &res,
}
resp, err := s.client.send(ctx, &sendOpt)
return &res, resp, err
}
// GetDocumentAuditingJobResult is the result of GetDocumentAuditingJob
type GetDocumentAuditingJobResult struct {
XMLName xml.Name `xml:"Response"`
JobsDetail *DocumentAuditingJobDetail `xml:",omitempty"`
RequestId string `xml:",omitempty"`
}
// DocumentAuditingJobDetail is the detail of GetDocumentAuditingJobResult
type DocumentAuditingJobDetail struct {
Code string `xml:",omitempty"`
Message string `xml:",omitempty"`
JobId string `xml:",omitempty"`
State string `xml:",omitempty"`
CreationTime string `xml:",omitempty"`
Object string `xml:",omitempty"`
Url string `xml:",omitempty"`
DataId string `xml:",omitempty"`
PageCount int `xml:",omitempty"`
Label string `xml:",omitempty"`
Suggestion int `xml:",omitempty"`
Labels *DocumentResultInfo `xml:",omitempty"`
PageSegment *DocumentPageSegmentInfo `xml:",omitempty"`
UserInfo *UserExtraInfo `xml:",omitempty"`
ListInfo *UserListInfo `xml:",omitempty"`
ForbidState int `xml:",omitempty"`
}
// DocumentResultInfo
type DocumentResultInfo struct {
PornInfo *RecognitionInfo `xml:",omitempty"`
TerrorismInfo *RecognitionInfo `xml:",omitempty"`
PoliticsInfo *RecognitionInfo `xml:",omitempty"`
AdsInfo *RecognitionInfo `xml:",omitempty"`
}
// DocumentPageSegmentInfo
type DocumentPageSegmentInfo struct {
Results []DocumentPageSegmentResultResult `xml:",omitempty"`
}
// DocumentPageSegmentResultResult
type DocumentPageSegmentResultResult struct {
Url string `xml:",omitempty"`
Text string `xml:",omitempty"`
PageNumber int `xml:",omitempty"`
SheetNumber int `xml:",omitempty"`
Label string `xml:",omitempty"`
Suggestion int `xml:",omitempty"`
PornInfo *RecognitionInfo `xml:",omitempty"`
TerrorismInfo *RecognitionInfo `xml:",omitempty"`
PoliticsInfo *RecognitionInfo `xml:",omitempty"`
AdsInfo *RecognitionInfo `xml:",omitempty"`
}
// OcrResult
type OcrResult struct {
Text string `xml:"Text,omitempty"`
Keywords []string `xml:"Keywords,omitempty"`
SubLabel string `xml:"SubLabel,omitempty"`
Location *Location `xml:"Location,omitempty"`
}
// ObjectResult
type ObjectResult struct {
Name string `xml:"Name,omitempty"`
SubLabel string `xml:"SubLabel,omitempty"`
Location *Location `xml:"Location,omitempty"`
}
// LibResult
type LibResult struct {
ImageId string `xml:"ImageId,omitempty"`
Score uint32 `xml:"Score,omitempty"`
TextLibResult
}
// Location
type Location struct {
X float64 `xml:"X,omitempty"` // 左上角横坐标
Y float64 `xml:"Y,omitempty"` // 左上角纵坐标
Width float64 `xml:"Width,omitempty"` // 宽度
Height float64 `xml:"Height,omitempty"` // 高度
Rotate float64 `xml:"Rotate,omitempty"` // 检测框的旋转角度
}
// 文档审核-查询任务 https://cloud.tencent.com/document/product/436/59382
func (s *CIService) GetDocumentAuditingJob(ctx context.Context, jobid string) (*GetDocumentAuditingJobResult, *Response, error) {
var res GetDocumentAuditingJobResult
sendOpt := sendOptions{
baseURL: s.client.BaseURL.CIURL,
uri: "/document/auditing/" + jobid,
method: http.MethodGet,
result: &res,
}
resp, err := s.client.send(ctx, &sendOpt)
return &res, resp, err
}
// PutWebpageAuditingJobOptions is the option of PutWebpageAuditingJob
type PutWebpageAuditingJobOptions struct {
XMLName xml.Name `xml:"Request"`
InputUrl string `xml:"Input>Url,omitempty"`
InputDataId string `xml:"Input>DataId,omitempty"`
InputUserInfo *UserExtraInfo `xml:"Input>UserInfo,omitempty"`
Conf *WebpageAuditingJobConf `xml:"Conf"`
}
// WebpageAuditingJobConf is the config of PutWebpageAuditingJobOptions
type WebpageAuditingJobConf struct {
DetectType string `xml:",omitempty"`
Callback string `xml:",omitempty"`
ReturnHighlightHtml bool `xml:",omitempty"`
BizType string `xml:",omitempty"`
CallbackType int `xml:",omitempty"`
}
// PutWebpageAuditingJobResult is the result of PutWebpageAuditingJob
type PutWebpageAuditingJobResult PutVideoAuditingJobResult
// 网页审核-创建任务 https://cloud.tencent.com/document/product/436/63958
func (s *CIService) PutWebpageAuditingJob(ctx context.Context, opt *PutWebpageAuditingJobOptions) (*PutWebpageAuditingJobResult, *Response, error) {
var res PutWebpageAuditingJobResult
sendOpt := sendOptions{
baseURL: s.client.BaseURL.CIURL,
uri: "/webpage/auditing",
method: http.MethodPost,
body: opt,
result: &res,
}
resp, err := s.client.send(ctx, &sendOpt)
return &res, resp, err
}
// GetWebpageAuditingJobResult is the result of GetWebpageAuditingJob
type GetWebpageAuditingJobResult struct {
XMLName xml.Name `xml:"Response"`
JobsDetail *WebpageAuditingJobDetail `xml:",omitempty"`
}
// WebpageAuditingJobDetail is the detail of GetWebpageAuditingJobResult
type WebpageAuditingJobDetail struct {
Code string `xml:",omitempty"`
Message string `xml:",omitempty"`
JobId string `xml:",omitempty"`
State string `xml:",omitempty"`
CreationTime string `xml:",omitempty"`
Url string `xml:",omitempty"`
Labels *WebpageResultInfo `xml:",omitempty"`
PageCount int `xml:",omitempty"`
Suggestion int `xml:",omitempty"`
ImageResults *WebpageImageResults `xml:",omitempty"`
TextResults *WebpageTextResults `xml:",omitempty"`
HighlightHtml string `xml:",omitempty"`
DataId string `xml:",omitempty"`
UserInfo *UserExtraInfo `xml:",omitempty"`
ListInfo *UserListInfo `xml:",omitempty"`
Label string `xml:",omitempty"`
}
// WebpageResultInfo
type WebpageResultInfo struct {
PornInfo *RecognitionInfo `xml:",omitempty"`
TerrorismInfo *RecognitionInfo `xml:",omitempty"`
PoliticsInfo *RecognitionInfo `xml:",omitempty"`
AdsInfo *RecognitionInfo `xml:",omitempty"`
IllegalInfo *RecognitionInfo `xml:",omitempty"`
AbuseInfo *RecognitionInfo `xml:",omitempty"`
}
// WebpageImageResults
type WebpageImageResults struct {
Results []WebpageImageResult `xml:",omitempty"`
}
// WebpageImageResult
type WebpageImageResult struct {
Url string `xml:",omitempty"`
Text string `xml:",omitempty"`
Label string `xml:",omitempty"`
PageNumber int `xml:",omitempty"`
SheetNumber int `xml:",omitempty"`
Suggestion int `xml:",omitempty"`
PornInfo *RecognitionInfo `xml:",omitempty"`
TerrorismInfo *RecognitionInfo `xml:",omitempty"`
PoliticsInfo *RecognitionInfo `xml:",omitempty"`
AdsInfo *RecognitionInfo `xml:",omitempty"`
}
// WebpageTextResults
type WebpageTextResults struct {
Results []WebpageTextResult `xml:",omitempty"`
}
// WebpageTextResult
type WebpageTextResult struct {
Text string `xml:",omitempty"`
Label string `xml:",omitempty"`
Result int `xml:",omitempty"`
PageNumber int `xml:",omitempty"`
SheetNumber int `xml:",omitempty"`
Suggestion int `xml:",omitempty"`
PornInfo *TextRecognitionInfo `xml:",omitempty"`
TerrorismInfo *TextRecognitionInfo `xml:",omitempty"`