main.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import os
  2. import sys
  3. import datetime
  4. import schedule
  5. import time
  6. sys.path.append(os.getcwd())
  7. from datetime import datetime
  8. from common import MysqlHelper, Common
  9. from video_stitching.video_stitching import VideoStitching
  10. from video_capture.douyin.douyin_author.douyin_author import douyinAuthor
  11. def get_account_id():
  12. current_time = datetime.now()
  13. formatted_time = current_time.strftime("%Y-%m-%d")
  14. count = f"""SELECT COUNT(*) AS total_count FROM ( SELECT audio, account_id FROM video_audio WHERE time = '{formatted_time}' GROUP BY audio, account_id) AS subquery;"""
  15. print(count)
  16. count = MysqlHelper.get_values(count, "prod")
  17. return count
  18. def job_video_stitching():
  19. # 在这里编写需要执行的任务代码
  20. count = get_account_id()
  21. if count == None:
  22. count = 0
  23. count = str(count).replace('(', '').replace(')', '').replace(',', '')
  24. if int(count) < 20:
  25. Common.logger().info("开始执行")
  26. VideoStitching.video_stitching()
  27. def job_douyin_data():
  28. douyinAuthor.get_videoList()
  29. # 设置下午2点运行任务
  30. schedule.every().day.at("14:00").do(job_douyin_data)
  31. schedule.every(15).minutes.do(job_video_stitching)
  32. while True:
  33. schedule.run_pending()
  34. time.sleep(1)