main.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. # 获取音画美文类数量
  12. def get_yinmei_account_id():
  13. current_time = datetime.now()
  14. formatted_time = current_time.strftime("%Y-%m-%d")
  15. 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;"""
  16. print(count)
  17. count = MysqlHelper.get_values(count, "prod")
  18. return count
  19. # 获取口播类数量
  20. def get_koubo_account_id():
  21. current_time = datetime.now()
  22. formatted_time = current_time.strftime("%Y-%m-%d")
  23. 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;"""
  24. print(count)
  25. count = MysqlHelper.get_values(count, "prod")
  26. return count
  27. def job_video_stitching():
  28. yinmei_count = get_yinmei_account_id()
  29. koubo_count = get_koubo_account_id()
  30. if koubo_count == None:
  31. koubo_count = 0
  32. if yinmei_count == None:
  33. yinmei_count = 0
  34. yinmei_count = str(yinmei_count).replace('(', '').replace(')', '').replace(',', '')
  35. koubo_count = str(koubo_count).replace('(', '').replace(')', '').replace(',', '')
  36. if int(yinmei_count) < 10:
  37. Common.logger().info("开始执行")
  38. video_type = "音画美文"
  39. VideoStitching.video_stitching(video_type)
  40. elif int(koubo_count) < 10:
  41. Common.logger().info("开始执行")
  42. video_type = "口播--美文类"
  43. VideoStitching.video_stitching(video_type)
  44. def job_douyin_data():
  45. douyinAuthor.get_videoList()
  46. # 每5个小时执行一次
  47. schedule.every(5).hours.do(job_douyin_data)
  48. # 每15分钟执行一次
  49. schedule.every(15).minutes.do(job_video_stitching)
  50. while True:
  51. schedule.run_pending()
  52. time.sleep(1)