video_count_notification.py 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import datetime
  2. import time
  3. from datetime import datetime
  4. import schedule
  5. from loguru import logger
  6. from common import Feishu
  7. from common.sql_help import sqlCollect
  8. def bot_carry_data():
  9. try:
  10. sph_feed_count = sqlCollect.get_channel_count("视频号推荐流", "视频号推荐流")
  11. ks_feed_count = sqlCollect.get_channel_count("快手推荐流", "快手推荐流")
  12. ks_xcx_count = sqlCollect.get_channel_count("快手小程序", "快手小程序")
  13. ks_sou_count = sqlCollect.get_channel_count("快手搜索", "品类关键词搜索")
  14. dy_sou_count = sqlCollect.get_channel_count("抖音搜索", "品类关键词搜索")
  15. sph_sou_count = sqlCollect.get_channel_count("视频号搜索", "品类关键词搜索")
  16. dy_count = sqlCollect.get_name_count("抖音品类账号")
  17. ks_count = sqlCollect.get_name_count("快手品类账号")
  18. sph_count = sqlCollect.get_name_count("视频号品类账号")
  19. xx_count = sqlCollect.get_name_count("信欣")
  20. dd_count = sqlCollect.get_name_count("单点视频")
  21. text = (
  22. f"**抖音品类账号**: {int(dy_count[0][0])}**/1500条**\n"
  23. f"**抖音搜索**: {int(dy_sou_count[0][0])}**/1200条**\n"
  24. f"**视频号品类账号**: {int(sph_count[0][0])}**/350条**\n"
  25. f"**视频号推荐流**: {int(sph_feed_count[0][0])}**/200条**\n"
  26. f"**视频号搜索**: {int(sph_sou_count[0][0])}**/100条**\n"
  27. f"**快手品类账号**: {int(ks_count[0][0])}**/900条**\n"
  28. f"**快手推荐流**: {int(ks_feed_count[0][0])}**/100条**\n"
  29. f"**快手小程序**: {int(ks_xcx_count[0][0])}**/?条**\n"
  30. f"**快手搜索**: {int(ks_sou_count[0][0])}**/650条**\n"
  31. f"**相似溯源(xx)**: {int(xx_count[0][0])}**/200条**\n"
  32. f"**单点视频**: {int(dd_count[0][0])}**条**\n"
  33. )
  34. Feishu.finish_bot(text,
  35. "https://open.feishu.cn/open-apis/bot/v2/hook/805ab4fe-0246-409c-b383-ea25831148e6",
  36. f"【 自制视频{datetime.now().strftime('%Y年%m月%d日 %H时')}数据通知 】")
  37. except Exception as e:
  38. logger.error(f"[+] 报警失败{e}")
  39. def schedule_tasks():
  40. schedule.every().hour.at(":05").do(bot_carry_data)
  41. if __name__ == "__main__":
  42. schedule_tasks() # 调用任务调度函数
  43. while True:
  44. schedule.run_pending()
  45. time.sleep(1) # 每秒钟检查一次
  46. # bot_carry_data()