Explorar el Código

修改定时任务

zhangyong hace 1 año
padre
commit
4c936256cc
Se han modificado 3 ficheros con 25 adiciones y 27 borrados
  1. 0 22
      douyin_run.py
  2. 23 2
      main.py
  3. 2 3
      video_stitching/video_stitching.py

+ 0 - 22
douyin_run.py

@@ -1,22 +0,0 @@
-
-import schedule
-import time
-import os
-import sys
-sys.path.append(os.getcwd())
-
-from video_capture.douyin.douyin_author.douyin_author import douyinAuthor
-
-
-
-
-def job_douyin_data():
-    douyinAuthor.get_videoList()
-
-# 设置下午2点运行任务
-schedule.every().day.at("14:00").do(job_douyin_data)
-
-
-while True:
-    schedule.run_pending()
-    time.sleep(1)

+ 23 - 2
main.py

@@ -2,13 +2,18 @@ import os
 import sys
 import sys
 import datetime
 import datetime
 
 
-
+import schedule
+import time
 sys.path.append(os.getcwd())
 sys.path.append(os.getcwd())
 from datetime import datetime
 from datetime import datetime
 from common import MysqlHelper, Common
 from common import MysqlHelper, Common
 
 
 from video_stitching.video_stitching import VideoStitching
 from video_stitching.video_stitching import VideoStitching
 
 
+from video_capture.douyin.douyin_author.douyin_author import douyinAuthor
+
+
+
 
 
 
 
 def get_account_id():
 def get_account_id():
@@ -18,11 +23,27 @@ def get_account_id():
     print(count)
     print(count)
     count = MysqlHelper.get_values(count, "prod")
     count = MysqlHelper.get_values(count, "prod")
     return count
     return count
-if __name__ == '__main__':
+
+def job_video_stitching():
+    # 在这里编写需要执行的任务代码
     count = get_account_id()
     count = get_account_id()
     count = str(count).replace('(', '').replace(')', '').replace(',', '')
     count = str(count).replace('(', '').replace(')', '').replace(',', '')
     if int(count) < 20:
     if int(count) < 20:
         Common.logger().info("开始执行")
         Common.logger().info("开始执行")
         VideoStitching.video_stitching()
         VideoStitching.video_stitching()
 
 
+def job_douyin_data():
+    douyinAuthor.get_videoList()
+
+# 设置下午2点运行任务
+schedule.every().day.at("14:00").do(job_douyin_data)
+
+schedule.every(15).minutes.do(job_video_stitching)
+
+while True:
+    schedule.run_pending()
+    time.sleep(1)
+
+
+
 
 

+ 2 - 3
video_stitching/video_stitching.py

@@ -183,8 +183,8 @@ class VideoStitching():
         final_clip = editor.CompositeVideoClip([final_clip, color_clip.set_position(("center", final_height - 100))])
         final_clip = editor.CompositeVideoClip([final_clip, color_clip.set_position(("center", final_height - 100))])
         # 处理SRT字幕文件
         # 处理SRT字幕文件
         subtitle_file = f"./video_stitching/video/{srt}.srt"
         subtitle_file = f"./video_stitching/video/{srt}.srt"
-        Common.logger().info(f"处理SRT字幕文件")
-        if os.path.exists(subtitle_file):
+        if os.path.isfile(subtitle_file):
+            Common.logger().info(f"处理SRT字幕文件")
             with open(subtitle_file, 'r') as file:
             with open(subtitle_file, 'r') as file:
                 subtitles = file.read().strip().split('\n\n')
                 subtitles = file.read().strip().split('\n\n')
             # 从SRT字幕文件中获取字幕
             # 从SRT字幕文件中获取字幕
@@ -201,7 +201,6 @@ class VideoStitching():
                 text = cls.split_text(text, 10)
                 text = cls.split_text(text, 10)
                 # /System/Library/Fonts/Hiragino Sans GB.ttc 本地字体
                 # /System/Library/Fonts/Hiragino Sans GB.ttc 本地字体
                 Common.logger().info(f"字幕:{text}")
                 Common.logger().info(f"字幕:{text}")
-
                 sub = editor.TextClip(text, font="/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc",
                 sub = editor.TextClip(text, font="/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc",
                                       fontsize=30, color="black").set_duration(end - start).set_start(
                                       fontsize=30, color="black").set_duration(end - start).set_start(
                     start).set_position(
                     start).set_position(