|
@@ -89,19 +89,21 @@ public class HkspSearch {
|
|
|
.execute();
|
|
.execute();
|
|
|
|
|
|
|
|
List<JSONObject> resultList = new ArrayList<>();
|
|
List<JSONObject> resultList = new ArrayList<>();
|
|
|
- System.out.println(response.body());
|
|
|
|
|
|
|
+ log.info("hkspSearch response:{}", response.body());
|
|
|
JSONObject jsonResponse = JSONObject.parseObject(response.body());
|
|
JSONObject jsonResponse = JSONObject.parseObject(response.body());
|
|
|
JSONArray dataList = jsonResponse.getJSONObject("data").getJSONArray("list");
|
|
JSONArray dataList = jsonResponse.getJSONObject("data").getJSONArray("list");
|
|
|
|
|
|
|
|
- for (int i = 0; i < dataList.size(); i++) {
|
|
|
|
|
- JSONObject data = dataList.getJSONObject(i);
|
|
|
|
|
- String videoId = data.getString("vid");
|
|
|
|
|
- String title = data.getString("title");
|
|
|
|
|
- int duration = parseDuration(data.getString("duration"));
|
|
|
|
|
- if (sensitiveFlag(sensitiveWords, title) && duration <= CrawlerConstant.MAX_VIDEO_DURATION) {
|
|
|
|
|
- JSONObject res = getVideoDetail(videoId);
|
|
|
|
|
- if (res != null) {
|
|
|
|
|
- resultList.add(res);
|
|
|
|
|
|
|
+ if (Objects.nonNull(dataList)) {
|
|
|
|
|
+ for (int i = 0; i < dataList.size(); i++) {
|
|
|
|
|
+ JSONObject data = dataList.getJSONObject(i);
|
|
|
|
|
+ String videoId = data.getString("vid");
|
|
|
|
|
+ String title = data.getString("title");
|
|
|
|
|
+ int duration = parseDuration(data.getString("duration"));
|
|
|
|
|
+ if (sensitiveFlag(sensitiveWords, title) && duration <= CrawlerConstant.MAX_VIDEO_DURATION) {
|
|
|
|
|
+ JSONObject res = getVideoDetail(videoId);
|
|
|
|
|
+ if (res != null) {
|
|
|
|
|
+ resultList.add(res);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|