job_keyword_dy.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import time
  2. import schedule
  3. from loguru import logger
  4. from common import Material
  5. from common.sql_help import sqlCollect
  6. from video_rewriting.video_processor import VideoProcessor
  7. def video_task_start():
  8. """抖视频搜索处理视频任务,返回用户名并根据结果决定延迟时间"""
  9. data = Material.feishu_list()[14]
  10. while True:
  11. try:
  12. count = sqlCollect.get_channel_count("抖音搜索", "品类关键词搜索")
  13. count = int(count[0][0])
  14. sheet_count = Material.get_count_restrict("抖音关键词搜索")
  15. if sheet_count:
  16. if count >= int(sheet_count):
  17. logger.info(f"[+] 到了限制数{count}")
  18. time.sleep(100)
  19. continue
  20. logger.info("[+] 开始执行任务")
  21. mark = VideoProcessor.main(data)
  22. logger.info(f"[+] 执行结束-{mark}")
  23. time.sleep(5)
  24. continue
  25. except Exception as e:
  26. logger.error("处理任务时出现异常:", e)
  27. time.sleep(10)
  28. continue
  29. def schedule_tasks():
  30. schedule.every(6).minutes.do(video_task_start)
  31. if __name__ == '__main__':
  32. video_task_start()
  33. # schedule_tasks() # 调用任务调度函数
  34. # while True:
  35. # schedule.run_pending()
  36. # time.sleep(1) # 每秒钟检查一次