1234567891011121314151617181920212223242526272829303132333435363738394041 |
- import time
- import schedule
- from loguru import logger
- from common import Material
- from common.sql_help import sqlCollect
- from video_rewriting.video_processor import VideoProcessor
- def video_task_start():
- """抖视频搜索处理视频任务,返回用户名并根据结果决定延迟时间"""
- data = Material.feishu_list()[14]
- while True:
- try:
- count = sqlCollect.get_channel_count("抖音搜索", "品类关键词搜索")
- count = int(count[0][0])
- sheet_count = Material.get_count_restrict("抖音关键词搜索")
- if sheet_count:
- if count >= int(sheet_count):
- logger.info(f"[+] 到了限制数{count}")
- time.sleep(100)
- continue
- logger.info("[+] 开始执行任务")
- mark = VideoProcessor.main(data)
- logger.info(f"[+] 执行结束-{mark}")
- time.sleep(5)
- continue
- except Exception as e:
- logger.error("处理任务时出现异常:", e)
- time.sleep(10)
- continue
- def schedule_tasks():
- schedule.every(6).minutes.do(video_task_start)
- if __name__ == '__main__':
- video_task_start()
- # schedule_tasks() # 调用任务调度函数
- # while True:
- # schedule.run_pending()
- # time.sleep(1) # 每秒钟检查一次
|