import os import sys import datetime import schedule import time sys.path.append(os.getcwd()) from datetime import datetime from common import MysqlHelper, Common from video_stitching.video_stitching import VideoStitching from video_capture.douyin.douyin_author.douyin_author import douyinAuthor # 获取音画美文类数量 def get_yinmei_account_id(): current_time = datetime.now() formatted_time = current_time.strftime("%Y-%m-%d") count = f"""SELECT COUNT(*) AS total_count FROM ( SELECT audio, account_id FROM video_audio WHERE time = '{formatted_time}' AND video_type = 0 GROUP BY audio, account_id) AS subquery;""" print(count) count = MysqlHelper.get_values(count, "prod") return count # 获取口播类数量 def get_koubo_account_id(): current_time = datetime.now() formatted_time = current_time.strftime("%Y-%m-%d") count = f"""SELECT COUNT(*) AS total_count FROM ( SELECT audio, account_id FROM video_audio WHERE time = '{formatted_time}' AND video_type = 1 GROUP BY audio, account_id) AS subquery;""" print(count) count = MysqlHelper.get_values(count, "prod") return count def job_video_stitching(): yinmei_count = get_yinmei_account_id() koubo_count = get_koubo_account_id() if koubo_count == None: koubo_count = 0 if yinmei_count == None: yinmei_count = 0 yinmei_count = str(yinmei_count).replace('(', '').replace(')', '').replace(',', '') koubo_count = str(koubo_count).replace('(', '').replace(')', '').replace(',', '') if int(yinmei_count) < 10: Common.logger().info("开始执行") video_type = "音画美文" VideoStitching.video_stitching(video_type) elif int(koubo_count) < 10: Common.logger().info("开始执行") video_type = "口播--美文类" VideoStitching.video_stitching(video_type) def job_douyin_data(): douyinAuthor.get_videoList() # 每5个小时执行一次 schedule.every(5).hours.do(job_douyin_data) # 每15分钟执行一次 schedule.every(15).minutes.do(job_video_stitching) while True: schedule.run_pending() time.sleep(1)