wangkun 2 yıl önce
ebeveyn
işleme
4b227ff7dc
3 değiştirilmiş dosya ile 28 ekleme ve 5 silme
  1. 25 3
      main/demo.py
  2. 2 1
      main/hour_list.py
  3. 1 1
      main/run_hour_list.py

+ 25 - 3
main/demo.py

@@ -7,6 +7,7 @@ from datetime import timedelta
 import requests
 import urllib3
 
+from main.common import Common
 from main.feishu_lib import Feishu
 
 proxies = {"http": None, "https": None}
@@ -104,10 +105,30 @@ class Demo:
     # 微信号
     @classmethod
     def get_sheet(cls):
-        hour_sheet = Feishu.get_values_batch("hour", "xiaoniangao", "ba0da4")
-        # print(hour_sheet)
+        hour_sheet = Feishu.get_values_batch("hour", "xiaoniangao", "FEcuil")
+        print(hour_sheet)
         print(hour_sheet[7][7])
 
+    @classmethod
+    def check_date(cls):
+        date = Feishu.get_values_batch("hour", "xiaoniangao", "FEcuil")
+        print(f'文档中L1:N1的日期:{date[0][11]}')
+        today = datetime.datetime.now().strftime("%Y-%m-%d")
+        print(f"today:{today}")
+        Common.logger("hour").info("检查今日上升榜日期是否存在")
+        if date[0][11] != today:
+            # 插入3列 L1:N1,并写入日期和时间数据
+            values = [[today], ["10:00", "15:00", "20:00"]]
+            time.sleep(1)
+            Feishu.insert_columns("hour", "xiaoniangao", "FEcuil", "COLUMNS", 11, 14)
+            time.sleep(1)
+            Feishu.update_values("hour", "xiaoniangao", "FEcuil", "L1:N2", values)
+            time.sleep(1)
+            Feishu.merge_cells("hour", "xiaoniangao", "FEcuil", "L1:N1")
+            Common.logger("hour").info("插入今天日期成功")
+        else:
+            Common.logger("hour").info("今日上升榜日期已存在")
+
 
 if __name__ == "__main__":
     demo = Demo()
@@ -120,4 +141,5 @@ if __name__ == "__main__":
     # demo.times()
 
     # demo.video_detail_info("44615236", "460972177", "62a9965e000001609aa588ad")
-    demo.get_sheet()
+    # demo.get_sheet()
+    demo.check_date()

+ 2 - 1
main/hour_list.py

@@ -17,6 +17,7 @@ proxies = {"http": None, "https": None}
 
 class HourList:
     # 配置微信
+    time.sleep(1)
     wechat_sheet = Feishu.get_values_batch("hour", "xiaoniangao", "dzcWHw")
     hour_x_b3_traceid = wechat_sheet[2][1]
     hour_x_token_id = wechat_sheet[3][1]
@@ -97,7 +98,7 @@ class HourList:
     def check_hour_list_data(cls, log_type, date):
         # 判断J1单元格的日期是否为今天
         time.sleep(1)
-        if Feishu.get_range_value(log_type, "xiaoniangao", "ba0da4", "L1:N1") != date:
+        if Feishu.get_range_value(log_type, "xiaoniangao", "ba0da4", "L1:L1")[0] != date:
             # 插入3列 L1:N1,并写入日期和时间数据
             values = [[date], ["10:00", "15:00", "20:00"]]
             time.sleep(1)

+ 1 - 1
main/run_hour_list.py

@@ -54,7 +54,7 @@ def hour_list_job():
 
 
 def run_update_hour_list():
-    HourList.update_hour_list_data("hour", "2022-07-01", "2022-06-30", "2022-06-29")
+    HourList.update_hour_list_data("hour", "2022-07-02", "2022-07-01", "2022-06-30")
 
 
 def run_download_and_publish():