zhangyong há 9 meses atrás
pai
commit
0c484c05b1
1 ficheiros alterados com 15 adições e 11 exclusões
  1. 15 11
      video_rewriting/video_processor.py

+ 15 - 11
video_rewriting/video_processor.py

@@ -60,15 +60,19 @@ class VideoProcessor:
         """
         删除指定目录下的所有文件和子目录
         """
-        path = config['PATHS']['VIDEO_PATH'] + mark + "/"
-        if os.path.exists(path) and os.path.isdir(path):
-            for root, dirs, files in os.walk(path):
-                for file in files:
-                    file_path = os.path.join(root, file)
-                    os.remove(file_path)
-                for dir in dirs:
-                    dir_path = os.path.join(root, dir)
-                    os.rmdir(dir_path)
+        try:
+            path = config['PATHS']['VIDEO_PATH'] + mark + "/"
+            if os.path.exists(path) and os.path.isdir(path):
+                for root, dirs, files in os.walk(path):
+                    for file in files:
+                        file_path = os.path.join(root, file)
+                        os.remove(file_path)
+                    for dir in dirs:
+                        dir_path = os.path.join(root, dir)
+                        os.rmdir(dir_path)
+        except:
+            pass
+
 
     @classmethod
     def process_task(cls, task, mark, name, feishu_id, cookie_sheet):
@@ -308,7 +312,7 @@ class VideoProcessor:
                         time.sleep(0.5)
                         Feishu.update_values("ILb4sa0LahddRktnRipcu2vQnLb", sheet, "A2:Z2", values)
             except Exception as e:
-                Common.logger(mark).info(f"{name}的{task_mark}任务处理失败:{e}")
+                Common.logger(mark).error(f"{name}的{task_mark}任务处理失败:{e}")
                 continue
 
     @classmethod
@@ -517,7 +521,7 @@ class VideoProcessor:
 
                 return code
         except Exception as e:
-            Common.logger("error").warning(f"{name}的{task_mark}上传视频和封面到OSS,并更新数据库失败:{e}\n")
+            Common.logger(mark).error(f"{name}的{task_mark}上传视频和封面到OSS,并更新数据库失败:{e}\n")
             return