|
@@ -11,10 +11,13 @@ import cn.com.ctop.crawler.modules.oceanengine.service.IDouyinHotService;
|
|
import cn.com.ctop.crawler.modules.oceanengine.service.IEffectCaseService;
|
|
import cn.com.ctop.crawler.modules.oceanengine.service.IEffectCaseService;
|
|
import cn.com.ctop.crawler.modules.oceanengine.service.IHotMaterialService;
|
|
import cn.com.ctop.crawler.modules.oceanengine.service.IHotMaterialService;
|
|
import cn.com.ctop.crawler.modules.oceanengine.service.IOceanEngineService;
|
|
import cn.com.ctop.crawler.modules.oceanengine.service.IOceanEngineService;
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.http.impl.cookie.BasicClientCookie;
|
|
import org.apache.http.impl.cookie.BasicClientCookie;
|
|
import org.bytedeco.javacv.FFmpegFrameGrabber;
|
|
import org.bytedeco.javacv.FFmpegFrameGrabber;
|
|
import org.bytedeco.javacv.Frame;
|
|
import org.bytedeco.javacv.Frame;
|
|
@@ -37,6 +40,7 @@ import java.util.List;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
|
|
+@Slf4j
|
|
public class OceanEngineServiceImpl implements IOceanEngineService {
|
|
public class OceanEngineServiceImpl implements IOceanEngineService {
|
|
@Value("${jeecg.path.chrome-driver}")
|
|
@Value("${jeecg.path.chrome-driver}")
|
|
private String chromeDriver;
|
|
private String chromeDriver;
|
|
@@ -66,7 +70,7 @@ public class OceanEngineServiceImpl implements IOceanEngineService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void hotMaterialHandler(int page, int appCode, String appName){
|
|
public void hotMaterialHandler(int page, int appCode, String appName){
|
|
- String result = HttpUtils2.httpGetRequest("https://cc.oceanengine.com/creative_center_server/api/hot_material/list?material_type=3&order_by=convert_show_rate&period_type=3&aggr_app_code="+appCode+"&page="+page+"&limit=20");
|
|
|
|
|
|
+ String result = HttpUtils2.httpGetRequest("https://cc.oceanengine.com/creative_center_server/api/hot_material/list?material_type=3&order_by=click_show_rate&period_type=30&aggr_app_code="+appCode+"&page="+page+"&limit=20");
|
|
System.out.println(result);
|
|
System.out.println(result);
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
|
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
|
@@ -121,49 +125,50 @@ public class OceanEngineServiceImpl implements IOceanEngineService {
|
|
public void effectCaseHandler(int page){
|
|
public void effectCaseHandler(int page){
|
|
String result = HttpUtils2.httpGetRequest("https://cc.oceanengine.com/creative_center_server/api/case/effect_case_list?industry=0&style=0&mode=0&page="+page+"&limit=20");
|
|
String result = HttpUtils2.httpGetRequest("https://cc.oceanengine.com/creative_center_server/api/case/effect_case_list?industry=0&style=0&mode=0&page="+page+"&limit=20");
|
|
System.out.println(result);
|
|
System.out.println(result);
|
|
- ObjectMapper mapper = new ObjectMapper();
|
|
|
|
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
|
|
|
try {
|
|
try {
|
|
- JsonNode node = mapper.readTree(result);
|
|
|
|
- int code = node.get("code").asInt();
|
|
|
|
- if(code == 0) {
|
|
|
|
- if (node.get("data") != null) {
|
|
|
|
- String dataJson = node.get("data").get("effect_cases").toString();
|
|
|
|
- List<EffectCase> list = mapper.readValue(dataJson,new TypeReference<List<EffectCase>>() {});
|
|
|
|
- if (list != null && list.size() > 0) {
|
|
|
|
- for (EffectCase effectCase:list){
|
|
|
|
- String resultDetail = HttpUtils2.httpGetRequest("https://cc.oceanengine.com/creative_center_server/api/case/effect_case/"+effectCase.getId());
|
|
|
|
- JsonNode detailNode = mapper.readTree(resultDetail);
|
|
|
|
- int detailCode = detailNode.get("code").asInt();
|
|
|
|
- if(detailCode == 0){
|
|
|
|
- if(detailNode.get("data") != null){
|
|
|
|
-// String detailJson = node.get("data").get("effect_cases").toString();
|
|
|
|
-// EffectCase effectCase1 = mapper.readValue(detailJson,EffectCase.class);
|
|
|
|
- effectCase.setAuthor(detailNode.get("data").get("effect_case").get("author").asText());
|
|
|
|
- effectCase.setCreateDate(detailNode.get("data").get("effect_case").get("create_date").asText());
|
|
|
|
- effectCase.setCreativeId(detailNode.get("data").get("effect_case").get("creative_id").asLong());
|
|
|
|
- effectCase.setCreativeScore(detailNode.get("data").get("effect_case").get("creative_score").asText());
|
|
|
|
- effectCase.setEffect(detailNode.get("data").get("effect_case").get("effect").toString());
|
|
|
|
- effectCase.setMethods(detailNode.get("data").get("effect_case").get("methods").toString());
|
|
|
|
- effectCase.setVideoUrl(getRealVideoUrl("https://aweme.snssdk.com/aweme/v1/playwm/?video_id="+effectCase.getVid()+"&line=0"));
|
|
|
|
- if (effectCase.getVideoUrl() == null){
|
|
|
|
- effectCase.setVideoUrl(getVideoUrl(effectCase.getVid()));
|
|
|
|
- }
|
|
|
|
-// effectCase.setVideoUrl(getVideoUrl(effectCase.getVid()));
|
|
|
|
- effectCase.setCoverImage(getVideoFirstImage(effectCase.getVideoUrl()));
|
|
|
|
- if (effectCase.getCoverImage() == null){
|
|
|
|
- Thread.sleep(1000);
|
|
|
|
- effectCase.setCoverImage(getVideoFirstImage(effectCase.getVideoUrl()));
|
|
|
|
- }
|
|
|
|
- effectCase.setCreativeLabel(detailNode.get("data").get("effect_case").get("creative_label").toString());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- effectCaseService.saveOrUpdate(effectCase);
|
|
|
|
- }
|
|
|
|
- effectCaseHandler(page+1);
|
|
|
|
|
|
+ ObjectMapper mapper = new ObjectMapper();
|
|
|
|
+ JSONObject node = JSONObject.parseObject(result);
|
|
|
|
+ Integer code = node.getInteger("code");
|
|
|
|
+ String message = node.getString("msg");
|
|
|
|
+ if(null==code||code != 0) {
|
|
|
|
+ log.error("巨量创意获取效果案例异常:{}",message);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ JSONArray effectCaseList = node.getJSONObject("data").getJSONArray("effect_cases");
|
|
|
|
+ if (effectCaseList == null || effectCaseList.isEmpty()) {
|
|
|
|
+ log.error("巨量创意获取效果案例数据为空:{}",message);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ List<EffectCase> effectCases = effectCaseList.toJavaList(EffectCase.class);
|
|
|
|
+ for (EffectCase effectCase:effectCases){
|
|
|
|
+ String resultDetail = HttpUtils2.httpGetRequest("https://cc.oceanengine.com/creative_center_server/api/case/effect_case/"+effectCase.getId());
|
|
|
|
+ JSONObject detailNode = JSONObject.parseObject(resultDetail);
|
|
|
|
+ Integer detailCode = detailNode.getInteger("code");
|
|
|
|
+ if(null ==detailCode|| detailCode != 0){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ JSONObject getCase = detailNode.getJSONObject("data").getJSONObject("effect_case");
|
|
|
|
+ if(getCase != null){
|
|
|
|
+ effectCase.setAuthor(getCase.getString("author"));
|
|
|
|
+ effectCase.setCreateDate(getCase.getString("create_date"));
|
|
|
|
+ effectCase.setCreativeId(getCase.getLong("creative_id"));
|
|
|
|
+ effectCase.setCreativeScore(getCase.getString("creative_score"));
|
|
|
|
+ effectCase.setEffect(getCase.getString("effect"));
|
|
|
|
+ effectCase.setMethods(getCase.getString("methods"));
|
|
|
|
+ effectCase.setVideoUrl(getRealVideoUrl("https://aweme.snssdk.com/aweme/v1/playwm/?video_id="+effectCase.getVid()+"&line=0"));
|
|
|
|
+ if (effectCase.getVideoUrl() == null){
|
|
|
|
+ effectCase.setVideoUrl(getVideoUrl(effectCase.getVid()));
|
|
|
|
+ }
|
|
|
|
+ effectCase.setCoverImage(getVideoFirstImage(effectCase.getVideoUrl()));
|
|
|
|
+ if (effectCase.getCoverImage() == null){
|
|
|
|
+ Thread.sleep(1000);
|
|
|
|
+ effectCase.setCoverImage(getVideoFirstImage(effectCase.getVideoUrl()));
|
|
}
|
|
}
|
|
|
|
+ effectCase.setCreativeLabel(getCase.getString("creative_label"));
|
|
}
|
|
}
|
|
|
|
+ effectCaseService.saveOrUpdate(effectCase);
|
|
}
|
|
}
|
|
|
|
+ effectCaseHandler(page+1);
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|