wangkun 2 anos atrás
pai
commit
3a0bdfaa1a
2 arquivos alterados com 25 adições e 2 exclusões
  1. 10 1
      main/feishu_lib.py
  2. 15 1
      main/run_bot.py

+ 10 - 1
main/feishu_lib.py

@@ -56,6 +56,8 @@ class Feishu:
     crawler_ganggangdouchuan = 'https://w42nne6hzg.feishu.cn/sheets/shtcnTuJgeZU2bc7VaesAqk3QJx'
     # 公众号_信欣
     crawler_gongzhonghao = 'https://w42nne6hzg.feishu.cn/sheets/shtcna98M2mX7TbivTj9Sb7WKBN?'
+    # youtube
+    crawler_youtube = 'https://w42nne6hzg.feishu.cn/sheets/shtcnrLyr1zbYbhhZyqpN7Xrd5f?'
 
     # 飞书路径token
     @classmethod
@@ -107,6 +109,8 @@ class Feishu:
             return 'shtcnTuJgeZU2bc7VaesAqk3QJx'
         elif crawler == 'gongzhonghao_xinxin':
             return 'shtcna98M2mX7TbivTj9Sb7WKBN'
+        elif crawler == 'youtube':
+            return 'shtcnrLyr1zbYbhhZyqpN7Xrd5f'
 
     # 获取飞书api token
     @classmethod
@@ -570,6 +574,11 @@ class Feishu:
                 sheet_url = "https://w42nne6hzg.feishu.cn/sheets/shtcn9rOdZRAGFbRkWpn7hqEHGc?sheet=KsVtLe"
                 users = "\n<at id=" + str(cls.get_userid(log_type, "wangkun")) + "></at> <at id=" + str(
                     cls.get_userid(log_type, "wuchaoyue")) + "></at>\n"
+            elif crawler == "youtube":
+                content = "youtube_定向_已下载表"
+                sheet_url = "https://w42nne6hzg.feishu.cn/sheets/shtcnrLyr1zbYbhhZyqpN7Xrd5f?sheet=GVxlYk"
+                users = "\n<at id=" + str(cls.get_userid(log_type, "wangkun")) + "></at> <at id=" + str(
+                    cls.get_userid(log_type, "wuchaoyue")) + "></at>\n"
 
             elif crawler == "zongjiao":
                 content = "宗教公众号爬虫表"
@@ -624,7 +633,7 @@ class Feishu:
 
 
 if __name__ == "__main__":
-    Feishu.bot("bot", "gongzhonghao_xinxin", "别紧张,还是我,测试一下")
+    Feishu.bot("bot", "youtube", "别紧张,还是我,测试一下")
     # print(Feishu.get_userid("shipinhao", "lijinchao"))
     
     pass

+ 15 - 1
main/run_bot.py

@@ -183,6 +183,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 == "youtube":
+                sheet = Feishu.get_values_batch(log_type, "youtube", "GVxlYk")
+                # 已下载表,最新一条视频抓取时间
+                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")
                 # 已下载表,最新一条视频抓取时间
@@ -350,6 +356,11 @@ class Bot:
                 Feishu.bot(log_type, crawler, "宗教公众号已下载表,超过24小时没有新视频入库了😤")
                 Common.logger(log_type).warning("宗教公众号已下载表,超过24小时没有新视频入库了😤\n")
 
+            # youtube
+            elif crawler == "youtube" and (int(time.time()) - cls.get_first_time(log_type, crawler) > int(duration)):
+                Feishu.bot(log_type, crawler, "youtube_定向_已下载表,超过24小时没有新视频入库了😤")
+                Common.logger(log_type).warning("youtube_定向_已下载表,超过24小时没有新视频入库了😤\n")
+
         except Exception as e:
             Common.logger(log_type).error(f"robot_alarm异常:{e}\n")
 
@@ -413,6 +424,9 @@ class Bot:
                 Common.logger("bot").info("刚刚都传已下载表")
                 Bot.robot_download_sheet("bot", "ggdc", duration)
 
+                Common.logger("bot").info("youtube_定向_已下载表")
+                Bot.robot_download_sheet("bot", "youtube", duration)
+
                 # Common.logger("bot").info("监控众妙音信已下载表")
                 # Bot.robot_download_sheet("bot", "zmyx", duration)
 
@@ -444,7 +458,7 @@ class Bot:
 
 if __name__ == "__main__":
 
-    # Bot.robot_download_sheet("bot", "gongzhonghao_xinxin", 1)
+    # Bot.robot_download_sheet("bot", "youtube", 1)
     Bot.main()
 
     pass