main.py 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import os
  2. import sys
  3. import schedule
  4. import time
  5. sys.path.append(os.getcwd())
  6. from common import Common, Feishu
  7. from common.sql_help import sql
  8. from video_stitching.video_stitching import VideoStitching
  9. flag = True
  10. def job_video_stitching():
  11. global flag
  12. dy_yinmei_count = sql.get_dy_yinmei_account_id()
  13. koubo_count = sql.get_koubo_account_id()
  14. # jieri_count = sql.get_jieri_account_id()
  15. # chunjie_zizhi_count = sql.get_chunjie_zizhi_account_id()
  16. ks_yinmei_count = sql.get_ks_yinmei_account_id()
  17. pjdouyin_account_id = sql.get_pjdouyin_account_id()
  18. ksdouyin_account_id = sql.get_ksdouyin_account_id()
  19. if int(ks_yinmei_count) < 10:
  20. Common.logger("video").info("开始执行-快手")
  21. video_type = "音画美文"
  22. channel_type = "kuaishou"
  23. VideoStitching.video_stitching(video_type, ks_yinmei_count, channel_type)
  24. elif int(dy_yinmei_count) < 10:
  25. Common.logger("video").info("开始执行-抖音")
  26. video_type = "音画美文"
  27. channel_type = "douyin"
  28. VideoStitching.video_stitching(video_type, dy_yinmei_count, channel_type)
  29. # elif int(chunjie_zizhi_count) < 10:
  30. # Common.logger("video").info("开始执行-自制-春节")
  31. # video_type = "自制--春节"
  32. # channel_type = "kschunjie"
  33. # VideoStitching.video_stitching(video_type, dy_yinmei_count, channel_type)
  34. # elif int(jieri_count) < 5:
  35. # Common.logger("video").info("开始执行-口播-春节")
  36. # video_type = "口播--美文类"
  37. # channel_type = "jieri"
  38. # VideoStitching.video_stitching(video_type, koubo_count, channel_type)
  39. elif int(koubo_count) < 10:
  40. Common.logger("video").info("开始执行-口播")
  41. video_type = "口播--美文类"
  42. channel_type = "koubo"
  43. VideoStitching.video_stitching(video_type, koubo_count, channel_type)
  44. elif int(pjdouyin_account_id) < 5:
  45. Common.logger("video").info("开始执行-抖音拼接")
  46. video_type = "抖音-拼接类"
  47. channel_type = "dypinjie"
  48. VideoStitching.video_stitching_pinjie(video_type, pjdouyin_account_id, channel_type)
  49. elif int(ksdouyin_account_id) < 5:
  50. Common.logger("video").info("开始执行-快手拼接")
  51. video_type = "快手-拼接类"
  52. channel_type = "kspinjie"
  53. VideoStitching.video_stitching_pinjie(video_type, ksdouyin_account_id, channel_type)
  54. count = int(dy_yinmei_count + koubo_count + ks_yinmei_count + pjdouyin_account_id + ksdouyin_account_id)
  55. Common.logger("video").info(f"视频生成条数为:{count}")
  56. if count == 40:
  57. if flag:
  58. Feishu.bot('recommend', '拼接视频', '自制视频拼接完成啦,共计40条~')
  59. flag = False
  60. if count == 0:
  61. flag = True
  62. def job_feishu_bot():
  63. # jieri_count = sql.get_jieri_account_id()
  64. dy_yinmei_count = sql.get_dy_yinmei_account_id()
  65. koubo_count = sql.get_koubo_account_id()
  66. ks_yinmei_count = sql.get_ks_yinmei_account_id()
  67. # chunjie_zizhi_count = sql.get_chunjie_zizhi_account_id()
  68. pjdouyin_account_id = sql.get_pjdouyin_account_id()
  69. ksdouyin_account_id = sql.get_ksdouyin_account_id()
  70. count = int(dy_yinmei_count + koubo_count + ks_yinmei_count + pjdouyin_account_id + ksdouyin_account_id)
  71. if count < 40:
  72. Feishu.bot('recommend', '拼接视频', f'视频生成异常,不符合预期,请检查\n目前生成数量如下:\n抖音-纯拼接类:{pjdouyin_account_id}条\n快手-纯拼接类:{ksdouyin_account_id}条\n抖音-拼接类:{dy_yinmei_count}条 \n快手-拼接类:{ks_yinmei_count}条\n口播-拼接类:{koubo_count}条')
  73. # 每15分钟执行一次
  74. schedule.every(15).minutes.do(job_video_stitching)
  75. # 每天下午1:30执行任务
  76. schedule.every().day.at("13:30").do(job_feishu_bot)
  77. while True:
  78. schedule.run_pending()
  79. time.sleep(1)