wangkun 2 years ago
parent
commit
d6899a1cf6
2 changed files with 6 additions and 3 deletions
  1. 3 0
      main/common.py
  2. 3 3
      main/publish.py

+ 3 - 0
main/common.py

@@ -97,6 +97,9 @@ class Common:
         视频封面,或视频播放地址:d_url
         下载保存路径:"./files/{d_title}/"
         """
+        videos_dir = r"./videos/"
+        if not os.path.exists(videos_dir):
+            os.mkdir(videos_dir)
         # 首先创建一个保存该视频相关信息的文件夹
         video_dir = "./videos/" + str(d_name) + "/"
         if not os.path.exists(video_dir):

+ 3 - 3
main/publish.py

@@ -7,14 +7,12 @@
 """
 import json
 import os
-import random
+import shutil
 import time
-
 import oss2
 import requests
 import urllib3
 from main.common import Common
-
 proxies = {"http": None, "https": None}
 
 
@@ -258,4 +256,6 @@ class Publish:
                 else:
                     Common.logger(log_type).error('file not a dir = {}'.format(fi_d))
             except Exception as e:
+                # 删除视频文件夹
+                shutil.rmtree("./videos/" + f + "/")
                 Common.logger(log_type).exception('upload_and_publish error', e)