job_keyword_dy.py 1.2 KB

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