12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- from common import Feishu, Material
- from common.sql_help import sqlHelp
- from video_agc.agc_video_method import AgcVidoe
- import schedule
- import threading
- import time
- # 记录今天已经返回的用户名
- returned_usernames_today = set()
- def video_start(user_data):
- global returned_usernames_today
- user_data_mark = user_data[0]["mark"]
- # 开始准备执行生成视频脚本
- if user_data_mark is not None and user_data_mark in returned_usernames_today:
- print(f"视频脚本参数中的用户名 {user_data_mark} 今天已经返回过,不再启动线程。")
- return # 如果返回了某个用户名,并且今天已经返回过,则不启动线程
- elif user_data_mark is not None:
- print(f"视频脚本参数{user_data}")
- mark = AgcVidoe.video_stitching(user_data)
- returned_usernames_today.add(mark)
- # 定义定时任务
- def video_task():
- print("开始执行生成视频脚.")
- data = Material.feishu_list()
- threads = []
- for _, user_data in data.iterrows():
- thread = threading.Thread(target=video_start, args=(user_data,))
- threads.append(thread)
- thread.start()
- for thread in threads:
- thread.join()
- print("执行生成视频脚结束")
- schedule.every(10).minutes.do(video_task)
- # 每天0点清空集合
- schedule.every().day.at("00:00").do(lambda: returned_usernames_today.clear())
- def job_feishu_bot():
- name_list = Material.feishu_name()
- count_list = sqlHelp.get_count_list(name_list)
- Feishu.bot('recommend', 'AGC视频', f'{"".join(count_list)}', 'all')
- print("机器人通知完成")
- # 每天下午1:30执行任务
- schedule.every().day.at("15:00").do(job_feishu_bot)
- while True:
- schedule.run_pending()
- time.sleep(1)
- # list = Material.feishu_list()
- # AgcVidoe.video_stitching(list)
- # print(list)
|