zhangyong há 6 meses atrás
pai
commit
dd4259e888

+ 3 - 2
analyze_video.py

@@ -17,11 +17,12 @@ async def process_video(request: VideoRequest):
     try:
     try:
         print("来一个请求")
         print("来一个请求")
         # 确保 main 函数是异步的
         # 确保 main 函数是异步的
-        result = await main(video_path)
+        result, mark = await main(video_path)
         return {
         return {
             "code": 0,
             "code": 0,
             "message": "视频处理成功",
             "message": "视频处理成功",
-            "result": result
+            "result": result,
+            "mark": mark
         }
         }
     except Exception as e:
     except Exception as e:
         raise HTTPException(status_code=500, detail=f"视频处理失败: {str(e)}")
         raise HTTPException(status_code=500, detail=f"视频处理失败: {str(e)}")

+ 1 - 1
common/redis.py

@@ -52,7 +52,7 @@ def get_video_data(redis_task):
     # task = redis_task
     # task = redis_task
     helper = SyncRedisHelper()
     helper = SyncRedisHelper()
     client = helper.get_client()
     client = helper.get_client()
-    ret = client.lpop(redis_task)
+    ret = client.rpop(redis_task)
     return ret
     return ret
 
 
 def in_video_data(ret):
 def in_video_data(ret):

+ 3 - 3
job_redis_data.py

@@ -8,7 +8,7 @@ def bot_video_ai_top():
     """头部"""
     """头部"""
     dt = datetime.datetime.now().strftime('%Y%m%d')
     dt = datetime.datetime.now().strftime('%Y%m%d')
     dt = '20241014'
     dt = '20241014'
-    redis_task = 'task:video_ai_top'
+    redis_task = 'task:video_ai'
     table_name = 'content_ai_tag_return_top'
     table_name = 'content_ai_tag_return_top'
     install_video_data(dt, redis_task, table_name)
     install_video_data(dt, redis_task, table_name)
 
 
@@ -18,7 +18,7 @@ def bot_video_ai_recommend():
     """新推荐"""
     """新推荐"""
     dt = datetime.datetime.now().strftime('%Y%m%d%H')
     dt = datetime.datetime.now().strftime('%Y%m%d%H')
     dt = '2024101514'
     dt = '2024101514'
-    redis_task = 'task:video_ai_recommend'
+    redis_task = 'task:video_ai'
     table_name = 'content_ai_tag_recommend'
     table_name = 'content_ai_tag_recommend'
     install_video_data(dt, redis_task, table_name)
     install_video_data(dt, redis_task, table_name)
 
 
@@ -27,7 +27,7 @@ def bot_video_ai_complex_mode():
     """复推"""
     """复推"""
     dt = datetime.datetime.now().strftime('%Y%m%d%H')
     dt = datetime.datetime.now().strftime('%Y%m%d%H')
     dt = '2024101514'
     dt = '2024101514'
-    redis_task = 'task:video_ai_complex_mode'
+    redis_task = 'task:video_ai'
     table_name = 'content_ai_tag_reflowpool'
     table_name = 'content_ai_tag_reflowpool'
     install_video_data(dt, redis_task, table_name)
     install_video_data(dt, redis_task, table_name)
 
 

+ 2 - 1
job_video_processing.py

@@ -10,7 +10,7 @@ def video_ai_task_start():
     with ThreadPoolExecutor( max_workers=max_workers) as executor:
     with ThreadPoolExecutor( max_workers=max_workers) as executor:
         while True:
         while True:
             try:
             try:
-                redis_task_list = ['task:video_ai_top', 'task:video_ai_recommend', 'task:video_ai_complex_mode']
+                redis_task_list = ['task:video_ai']
                 # 提交所有任务并等待完成
                 # 提交所有任务并等待完成
                 futures = [executor.submit( process_video_ai, redis_task ) for redis_task in redis_task_list]
                 futures = [executor.submit( process_video_ai, redis_task ) for redis_task in redis_task_list]
                 wait( futures )  # 等待所有任务完成
                 wait( futures )  # 等待所有任务完成
@@ -21,6 +21,7 @@ def video_ai_task_start():
 
 
 def process_video_ai(redis_task):
 def process_video_ai(redis_task):
     try:
     try:
+
         print(f"开始执行任务{redis_task}")
         print(f"开始执行任务{redis_task}")
         video_processor = VideoProcessing()
         video_processor = VideoProcessing()
         video_processor.get_video(redis_task)
         video_processor.get_video(redis_task)

+ 4 - 2
video_processing/video_processing.py

@@ -18,11 +18,13 @@ class VideoProcessing:
             'Content-Type': 'application/json'
             'Content-Type': 'application/json'
         }
         }
         try:
         try:
-            response, mark = requests.request( "POST", url, headers=headers, data=payload )
+            response = requests.request( "POST", url, headers=headers, data=payload )
             response = response.json()
             response = response.json()
             result = response['result']
             result = response['result']
+            mark = response['mark']
+
             cleaned_string = result.replace( "```json", '' ).replace( "```", '' ).strip()
             cleaned_string = result.replace( "```json", '' ).replace( "```", '' ).strip()
-            return cleaned_string, mark
+            return cleaned_string, str(mark)
         except Exception as e:
         except Exception as e:
             print(f"视频请求异常:{e}")
             print(f"视频请求异常:{e}")
             return None
             return None