|
@@ -1,46 +1,25 @@
|
|
|
import os
|
|
|
import sys
|
|
|
-import threading
|
|
|
-import schedule
|
|
|
-import time
|
|
|
-import functools
|
|
|
+
|
|
|
|
|
|
sys.path.append(os.getcwd())
|
|
|
-from common.db import MysqlHelper
|
|
|
from video_capture.douyin.douyin_author.douyin_author import douyinAuthor
|
|
|
from video_stitching.video_stitching import VideoStitching
|
|
|
-from datetime import datetime, timedelta
|
|
|
-
|
|
|
-def get_count():
|
|
|
- current_time = datetime.now()
|
|
|
- previous_time = current_time - timedelta(minutes=10)
|
|
|
- previous_time_str = previous_time.strftime("%Y-%m-%d %H:%M")
|
|
|
- select_user_sql = f"""select video_id from video_url where time >="{previous_time_str}";"""
|
|
|
- count = MysqlHelper.get_values(select_user_sql, "prod")
|
|
|
- if count:
|
|
|
- return True
|
|
|
- else:
|
|
|
- return False
|
|
|
-
|
|
|
-def check_token():
|
|
|
- while True:
|
|
|
- count = get_count()
|
|
|
- if count:
|
|
|
- time.sleep(6 * 60 * 60) # 每6小时检查一次
|
|
|
- else:
|
|
|
- douyinAuthor.get_token()
|
|
|
+import schedule
|
|
|
+import time
|
|
|
|
|
|
-# 创建并启动线程
|
|
|
-token_thread = threading.Thread(target=check_token)
|
|
|
-token_thread.start()
|
|
|
+def job_video_stitching():
|
|
|
+ VideoStitching.video_stitching()
|
|
|
|
|
|
-# 每天下午4点定时启动 video_stitching 方法
|
|
|
-def execute_video_stitching():
|
|
|
- VideoStitching.video_stitching() # 在此处调用你想要执行的函数
|
|
|
+def job_douyin_data():
|
|
|
+ douyinAuthor.get_token()
|
|
|
|
|
|
-schedule.every().day.at("16:00").do(execute_video_stitching)
|
|
|
+# 设置上午10点运行任务
|
|
|
+schedule.every().day.at("10:00").do(job_douyin_data)
|
|
|
|
|
|
+# 设置下午4点运行任务
|
|
|
+schedule.every().day.at("16:00").do(job_video_stitching)
|
|
|
|
|
|
while True:
|
|
|
schedule.run_pending()
|
|
|
- time.sleep(1)
|
|
|
+ time.sleep(1)
|