瀏覽代碼

update run_time

wangkun 3 年之前
父節點
當前提交
2d4f8fb2ec
共有 2 個文件被更改,包括 14 次插入9 次删除
  1. 1 1
      main/common.py
  2. 13 8
      main/run_recommend.py

+ 1 - 1
main/common.py

@@ -64,7 +64,7 @@ class Common:
         清除冗余日志文件
         :return: 保留最近 7 个日志
         """
-        log_dir = r"./logs/"
+        log_dir = "./logs/"
         all_files = sorted(os.listdir(log_dir))
         all_logs = []
         for log in all_files:

+ 13 - 8
main/run_recommend.py

@@ -3,6 +3,7 @@
 # @Time: 2022/6/17
 import datetime
 import os
+import random
 import sys
 import time
 sys.path.append(os.getcwd())
@@ -15,14 +16,18 @@ class Main:
     @classmethod
     def prod_job(cls):
         while True:
-            prod_job_time = datetime.datetime.now()
-            if prod_job_time.hour == 0 and prod_job_time.minute <= 10:
-                Common.del_logs("recommend")
-                Common.del_charles_files("recommend")
-                time.sleep(60)
-            else:
-                get_feeds("recommend")
-                DownloadPlaySendtime.run_download_play_sendtime("prod")
+            while True:
+                prod_job_time = datetime.datetime.now()
+                if 1 >= prod_job_time.hour >= 0:
+                    break
+                else:
+                    Common.logger("recommend").info("开始抓取看一看+推荐列表")
+                    get_feeds("recommend")
+                    DownloadPlaySendtime.run_download_play_sendtime("prod")
+                    Common.del_logs("recommend")
+                    Common.del_charles_files("recommend")
+                    time.sleep(random.randint(3, 5))
+                    break
 
 
 if __name__ == "__main__":