From 2b1f542577dd8dfc54d3433dff3615796ceab0af Mon Sep 17 00:00:00 2001
From: shikeying <shikeying@163.com>
Date: 星期二, 11 十月 2022 17:17:50 +0800
Subject: [PATCH] 视频下载,解析分析调度跑通

---
 recommend-video/src/main/java/com/iplatform/recvideo/util/PythonInvokeUtils.java |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/recommend-video/src/main/java/com/iplatform/recvideo/util/PythonInvokeUtils.java b/recommend-video/src/main/java/com/iplatform/recvideo/util/PythonInvokeUtils.java
index a315bb2..e53bf0d 100644
--- a/recommend-video/src/main/java/com/iplatform/recvideo/util/PythonInvokeUtils.java
+++ b/recommend-video/src/main/java/com/iplatform/recvideo/util/PythonInvokeUtils.java
@@ -18,6 +18,36 @@
 
     private static final transient Logger logger = LoggerFactory.getLogger(PythonInvokeUtils.class);
 
+    public static boolean postLoadVideoGather(String batchId, String url, RestTemplate restTemplate) throws Exception{
+        LoadRequest request = new LoadRequest();
+        request.setDate(batchId);
+        request.setFrame_rate("30");
+
+        ResponseEntity<String> entity = restTemplate.postForEntity(url, request, String.class);
+        if(entity == null){
+            return false;
+        }
+        String jsonData = entity.getBody();
+        try {
+            Map<String, Object> map = JsonUtils.jsonStringToObject(jsonData, Map.class);
+            if(map == null || !map.containsKey("code")){
+                logger.error("python杩斿洖缁撴灉涓虹┖锛屾垨鑰呮病鏈塩ode鏍囧織锛屾棤娉曞垽鏂皟鐢ㄥ姞杞借棰戞垚鍔�!");
+                return false;
+            }
+            String code = map.get("code").toString();
+            if(code.equals("0")){
+                logger.info("python notify_gather_once() 鍔犺浇瑙嗛澶勭悊鎴愬姛! batchId = " + batchId);
+                return true;
+            }
+            logger.warn("python notify_gather_once() 鍔犺浇瑙嗛澶勭悊澶辫触, batchId = " + batchId);
+            return false;
+
+        } catch (Exception e) {
+            logger.error("瑙f瀽json缁撴灉閿欒:" + jsonData, e);
+            throw e;
+        }
+    }
+
     public static List<Rc_video_t1> acquireImageSearchResult(String videoId, String imgPath
             , String topN, String url, RestTemplate restTemplate) throws Exception{
         SearchRequest request = new SearchRequest();
@@ -55,6 +85,8 @@
      * @return
      */
     public static final String getFileNameWithoutSuffix(String videoPath, String suffix){
+        // 濡傛灉瀛樺湪windows鍙嶆枩鏉狅紝鍏堣浆鎹㈡垚姝f枩鏉犮��2022-10-11
+        videoPath = videoPath.replaceAll("\\\\", StringUtils.FOLDER_SEPARATOR);
         String[] array = videoPath.split("/");
         if(array == null || array.length == 0){
             logger.error("瑙嗛鍚嶇О鎴彇id閿欒:" + videoPath);

--
Gitblit v1.9.1