main.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. # 每5个小时执行一次
  30. schedule.every(5).hours.do(job_douyin_data)
  31. # 每15分钟执行一次
  32. schedule.every(15).minutes.do(job_video_stitching)
  33. while True:
  34. schedule.run_pending()
  35. time.sleep(1)