Browse Source

add 条数限制

zhangyong 1 year ago
parent
commit
500a2aa55f
1 changed files with 10 additions and 1 deletions
  1. 10 1
      zhufushenghuo/zhufushenghuo_recommend/zfsh_recommend.py

+ 10 - 1
zhufushenghuo/zhufushenghuo_recommend/zfsh_recommend.py

@@ -20,7 +20,10 @@ headers = {
         }
 
 class ZfshRecommend:
-    platform = ("祝福生活视频")
+    platform = ("祝福生活")
+    download_cnt = 0
+    element_list = []
+    i = 0
 
     @classmethod
     def get_video_url(cls, id, uuid1, log_type, crawler, env):
@@ -105,6 +108,12 @@ class ZfshRecommend:
                     feeds = r.json()["data"]["list"]
                     for i in range(len(feeds)):
                         try:
+                            if cls.download_cnt >= int(rule_dict.get("videos_cnt", {}).get("min", 10)):
+                                cls.i = 0
+                                cls.download_cnt = 0
+                                cls.element_list = []
+                                return
+                            cls.i += 1
                             video_title = feeds[i].get("title", "").strip().replace("\n", "") \
                                 .replace("/", "").replace("\\", "").replace("\r", "") \
                                 .replace(":", "").replace("*", "").replace("?", "") \