zhangyong 8 months ago
parent
commit
ce96b5dfca
2 changed files with 10 additions and 4 deletions
  1. 6 1
      common/aliyun_log.py
  2. 4 3
      video_rewriting/video_processor.py

+ 6 - 1
common/aliyun_log.py

@@ -9,6 +9,8 @@ from typing import Optional
 
 from aliyun.log import PutLogsRequest, LogClient, LogItem
 
+from common import Common
+
 proxies = {"http": None, "https": None}
 
 
@@ -70,4 +72,7 @@ class AliyunLogger:
             logitems=log_group,
             compress=False,
         )
-        client.put_logs(request)
+        try:
+            client.put_logs(request)
+        except Exception as e:
+            Common.logger('aliyun').error(f"写入日志失败: {e}")

+ 4 - 3
video_rewriting/video_processor.py

@@ -156,7 +156,7 @@ class VideoProcessor:
 
                     if not os.path.isfile(new_video_path):
                         log_data = f"user:{url},video_id:{v_id},video_url:{video_url},ai_title:{new_title}"
-                        AliyunLogger.logging(channel_id, name, url, v_id, "视频改造失败", "3001", f"video_url:{log_data}")
+                        AliyunLogger.logging(channel_id, name, url, v_id, "视频改造失败", "3001", log_data)
                         text = (
                             f"**通知类型**: 视频改造失败\n"
                             f"**负责人**: {name}\n"
@@ -200,12 +200,13 @@ class VideoProcessor:
                         f"**视频主页ID**: {url}\n"
                         f"**视频Video_id**: {v_id}\n"
                     )
-                    log_data = f"user:{url},video_id:{v_id},video_url:{video_url},ai_title:{new_title}"
-                    AliyunLogger.logging(channel_id, name, url, v_id, "视频改造成功", "1000", log_data, code)
+
 
                     Feishu.finish_bot(text,
                                       "https://open.feishu.cn/open-apis/bot/v2/hook/e7697dc6-5254-4411-8b59-3cd0742bf703",
                                       "【 机器改造通知 】")
+                    log_data = f"user:{url},video_id:{v_id},video_url:{video_url},ai_title:{new_title}"
+                    AliyunLogger.logging(channel_id, name, url, v_id, "视频改造成功", "1000", log_data, str(code))
                     if channel_id == "快手历史" or channel_id == "抖音历史" or channel_id == "视频号历史":
                         explain = "历史爆款"
                     else: