Explorar el Código

快手 兼容多cookie

zhangyong hace 11 meses
padre
commit
e3846dd880
Se han modificado 1 ficheros con 9 adiciones y 1 borrados
  1. 9 1
      kuaishou/kuaishou_author/kuaishou_author_scheduling_new.py

+ 9 - 1
kuaishou/kuaishou_author/kuaishou_author_scheduling_new.py

@@ -22,6 +22,7 @@ from common.public import random_title, get_config_from_mysql, download_rule
 from common.limit import AuthorLimit
 
 
+
 class KuaishouauthorScheduling:
     platform = "快手"
     download_cnt = 0
@@ -126,7 +127,12 @@ class KuaishouauthorScheduling:
                 },
                 "query": "fragment photoContent on PhotoEntity {\n  id\n  duration\n  caption\n  originCaption\n  likeCount\n  viewCount\n  commentCount\n  realLikeCount\n  coverUrl\n  photoUrl\n  photoH265Url\n  manifest\n  manifestH265\n  videoResource\n  coverUrls {\n    url\n    __typename\n  }\n  timestamp\n  expTag\n  animatedCoverUrl\n  distance\n  videoRatio\n  liked\n  stereoType\n  profileUserTopPhoto\n  musicBlocked\n  __typename\n}\n\nfragment feedContent on Feed {\n  type\n  author {\n    id\n    name\n    headerUrl\n    following\n    headerUrls {\n      url\n      __typename\n    }\n    __typename\n  }\n  photo {\n    ...photoContent\n    __typename\n  }\n  canAddComment\n  llsid\n  status\n  currentPcursor\n  tags {\n    type\n    name\n    __typename\n  }\n  __typename\n}\n\nquery visionProfilePhotoList($pcursor: String, $userId: String, $page: String, $webPageArea: String) {\n  visionProfilePhotoList(pcursor: $pcursor, userId: $userId, page: $page, webPageArea: $webPageArea) {\n    result\n    llsid\n    webPageArea\n    feeds {\n      ...feedContent\n      __typename\n    }\n    hostName\n    pcursor\n    __typename\n  }\n}\n"
             })
-            cookie = cls.get_cookie(log_type, crawler, env)["cookie"]
+            cookie_list = cls.get_cookie(log_type, crawler, env)["cookie"]
+            if ',' in cookie_list:
+                cookie_list = cookie_list.split(',')
+                cookie = random.choice(cookie_list)
+            else:
+                cookie = [cookie_list]
             headers = {
                 'Accept': '*/*',
                 'Content-Type': 'application/json',
@@ -179,6 +185,7 @@ class KuaishouauthorScheduling:
                     env=env,
                     message=f"response:{response.json()}\n"
                 )
+                Feishu.bot(log_type, 'kuaishou', f'快手cookie失效,请及时更换~')
                 return
             elif "feeds" not in response.json()["data"]["visionProfilePhotoList"]:
                 Common.logger(log_type, crawler).warning(f"response:{response.json()}\n")
@@ -189,6 +196,7 @@ class KuaishouauthorScheduling:
                     env=env,
                     message=f"response:{response.json()}\n"
                 )
+                Feishu.bot(log_type, 'kuaishou', f'快手cookie失效,请及时更换~')
                 return
             elif len(response.json()["data"]["visionProfilePhotoList"]["feeds"]) == 0:
                 Common.logger(log_type, crawler).warning(f"没有更多视频啦 ~\n")