@@ -20,9 +20,16 @@ public static void main(String args[]) {
20
20
ResourcesCensor resourcesCensor = new ResourcesCensor ();
21
21
String result ;
22
22
try {
23
- result = resourcesCensor .ImageCensor ();
24
- //result = resourcesCensor.VideoCensor();
25
- System .out .printf (result );
23
+ //result = resourcesCensor.ImageCensor();
24
+ result = resourcesCensor .VideoCensor ();
25
+ System .out .println (result );
26
+
27
+ /* 只有视频审核才会返回jobID */
28
+ Gson gson = new Gson ();
29
+ Map <String , String > jobMap = new HashMap ();
30
+ String jobID = (String ) gson .fromJson (result , jobMap .getClass ()).get ("job" );
31
+ String videoCensorResult = resourcesCensor .getVideoCensorResultByJobID (jobID );
32
+ System .out .println (videoCensorResult );
26
33
} catch (QiniuException e ) {
27
34
e .printStackTrace ();
28
35
}
@@ -88,13 +95,33 @@ public String VideoCensor() throws QiniuException {
88
95
return post (url , bodyByte );
89
96
}
90
97
98
+ /**
99
+ *
100
+ * @param ID : 视频审核返回的 job ID
101
+ *
102
+ */
103
+ public String getVideoCensorResultByJobID (String ID ){
104
+ String url = "http://ai.qiniuapi.com/v3/jobs/video/" .concat (ID );
105
+ String accessToken = (String ) auth .authorizationV2 (url ).get ("Authorization" );
106
+ StringMap headers = new StringMap ();
107
+ headers .put ("Authorization" , accessToken );
108
+
109
+ try {
110
+ com .qiniu .http .Response resp = client .get (url ,headers );
111
+ return resp .bodyString ();
112
+ } catch (Exception e ) {
113
+ e .printStackTrace ();
114
+ }
115
+ return null ;
116
+ }
117
+
91
118
private String post (String url , byte [] body ) throws QiniuException {
92
119
String accessToken = (String ) auth .authorizationV2 (url , "POST" , body , "application/json" )
93
120
.get ("Authorization" );
94
121
95
122
StringMap headers = new StringMap ();
96
123
headers .put ("Authorization" , accessToken );
97
-
124
+
98
125
com .qiniu .http .Response resp = client .post (url , body , headers , Client .JsonMime );
99
126
return resp .bodyString ();
100
127
}
0 commit comments