|
@@ -59,6 +59,12 @@ class Bot:
|
|
|
# 已下载表,最新一条视频抓取时间
|
|
|
first_download_time = sheet[1][5]
|
|
|
first_download_time = int(time.mktime(time.strptime(first_download_time, "%Y/%m/%d %H:%M:%S")))
|
|
|
+ elif crawler == "weishi":
|
|
|
+ sheet = Feishu.get_values_batch(log_type, "weishi", "caa3fa")
|
|
|
+ # print(sheet[1])
|
|
|
+ # 已下载表,最新一条视频抓取时间
|
|
|
+ first_download_time = sheet[1][5]
|
|
|
+ first_download_time = int(time.mktime(time.strptime(first_download_time, "%Y/%m/%d %H:%M:%S")))
|
|
|
else:
|
|
|
sheet = Feishu.get_values_batch(log_type, "xiaoniangao", "yatRv2")
|
|
|
# 已下载表,最新一条视频抓取时间
|
|
@@ -91,6 +97,8 @@ class Bot:
|
|
|
feeds_sheet = Feishu.get_values_batch(log_type, "kuaishou", "wW5cyb")
|
|
|
elif crawler == "gzh" and sheet == "recommend":
|
|
|
feeds_sheet = Feishu.get_values_batch(log_type, "gzh", "zWKFGb")
|
|
|
+ elif crawler == "weishi" and sheet == "recommend":
|
|
|
+ feeds_sheet = Feishu.get_values_batch(log_type, "weishi", "O7fCzr")
|
|
|
else:
|
|
|
feeds_sheet = "请输入{crawler}和{sheet}"
|
|
|
|
|
@@ -182,6 +190,12 @@ class Bot:
|
|
|
elif crawler == "weiqun" and (int(time.time()) - cls.get_first_time(log_type, crawler) > int(duration)):
|
|
|
Feishu.bot(log_type, crawler, "微群视频已下载表,超过24小时没有新视频入库了😤")
|
|
|
Common.logger(log_type).info("微群视频已下载表,超过24小时没有新视频入库了😤\n")
|
|
|
+
|
|
|
+ # 微视爬虫报警
|
|
|
+ elif crawler == "weishi" and (int(time.time()) - cls.get_first_time(log_type, crawler) > int(duration)):
|
|
|
+ Feishu.bot(log_type, crawler, "微视已下载表,超过24小时没有新视频入库了😤")
|
|
|
+ Common.logger(log_type).info("微视已下载表,超过24小时没有新视频入库了😤\n")
|
|
|
+
|
|
|
except Exception as e:
|
|
|
Common.logger(log_type).error("robot_alarm异常:{}", e)
|
|
|
|
|
@@ -189,7 +203,7 @@ class Bot:
|
|
|
@classmethod
|
|
|
def main(cls):
|
|
|
"""
|
|
|
- 每隔一小时,检查一次已下载表;
|
|
|
+ 每隔六小时,检查一次已下载表;
|
|
|
已下载表的最新一条数据抓取时间,距当前时间超过 24 小时,则触发机器人报警,发送飞书报警消息
|
|
|
"""
|
|
|
# 已下载表,超过 24 小时无新视频入库报警
|
|
@@ -203,30 +217,33 @@ class Bot:
|
|
|
Common.logger("bot").info("监控小年糕已下载表")
|
|
|
Bot.robot_download_sheet("bot", "xiaoniangao", duration)
|
|
|
|
|
|
- # Common.logger("bot").info("监控音乐相册已下载表")
|
|
|
- # Bot.robot_download_sheet("bot", "music_album", duration)
|
|
|
-
|
|
|
Common.logger("bot").info("监控本山祝福已下载表")
|
|
|
Bot.robot_download_sheet("bot", "bszf", duration)
|
|
|
|
|
|
Common.logger("bot").info("监控快手已下载表")
|
|
|
Bot.robot_download_sheet("bot", "kuaishou", duration)
|
|
|
|
|
|
+ Common.logger("bot").info("监控微视已下载表")
|
|
|
+ Bot.robot_download_sheet("bot", "weishi", duration)
|
|
|
+
|
|
|
+ Common.logger("bot").info("监控公众号已下载表")
|
|
|
+ Bot.robot_download_sheet("bot", "gzh", duration)
|
|
|
+
|
|
|
+ # Common.logger("bot").info("监控音乐相册已下载表")
|
|
|
+ # Bot.robot_download_sheet("bot", "music_album", duration)
|
|
|
+
|
|
|
# Common.logger("bot").info("监控微群视频已下载表")
|
|
|
# Bot.robot_download_sheet("bot", "weiqun", duration)
|
|
|
|
|
|
- # Common.logger("bot").info("监控公众号已下载表")
|
|
|
- # Bot.robot_alarm("bot", "gzh", duration)
|
|
|
-
|
|
|
Common.del_logs("bot")
|
|
|
- Common.logger("bot").info("休眠 1 小时")
|
|
|
- time.sleep(21600)
|
|
|
+ Common.logger("bot").info("休眠 6 小时")
|
|
|
+ time.sleep(3600 * 6)
|
|
|
else:
|
|
|
- Common.logger("bot").info("今日监控完毕\n")
|
|
|
+ pass
|
|
|
+ # Common.logger("bot").info("今日监控完毕\n")
|
|
|
+ # time.sleep(3600 * (24-datetime.datetime.now().hour))
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
- # Bot.get_feeds_sheet("bot", "gzh", "recommend")
|
|
|
- # Bot.rebot_feeds_sheet("bot", "gzh", "recommend")
|
|
|
- # Bot.robot_download_sheet("bot", "weiqun", 10)
|
|
|
+ # Bot.robot_download_sheet("bot", "gzh", 10)
|
|
|
Bot.main()
|