wangkun před 2 roky
rodič
revize
f015d404a6
4 změnil soubory, kde provedl 417 přidání a 8 odebrání
  1. 4 0
      README.md
  2. 3 6
      main/follow_publish.py
  3. 408 0
      main/zhihu_follow.py
  4. 2 2
      main/zhihu_hot.py

+ 4 - 0
README.md

@@ -20,6 +20,10 @@
 
 
 #### 需求
+2022/11/02
+1. 发布时间<180天
+2. 视频播放量>3w
+
 2022/11/01
 1. 热榜规则:
    - 运行时间: 08:00:00 - 22:59:59 

+ 3 - 6
main/follow_publish.py

@@ -7,15 +7,12 @@
 """
 import json
 import os
-import random
 import shutil
 import time
-
 import oss2
 import requests
 import urllib3
 from main.common import Common
-
 proxies = {"http": None, "https": None}
 
 
@@ -37,11 +34,11 @@ class Publish:
         versionCode  版本 默认1
         :return:
         """
-        # Common.logger(log_type).info('publish request data: {}'.format(request_data))
+        Common.logger(log_type).info('publish request data: {}'.format(request_data))
         result = cls.request_post('https://videotest.yishihui.com/longvideoapi/crawler/video/send', request_data)
-        # Common.logger(log_type).info('publish result: {}'.format(result))
+        Common.logger(log_type).info('publish result: {}'.format(result))
         video_id = result["data"]["id"]
-        # Common.logger(log_type).info('video_id: {}'.format(video_id))
+        Common.logger(log_type).info('video_id: {}'.format(video_id))
         if result['code'] != 0:
             Common.logger(log_type).error('pushlish failure msg = {}'.format(result['msg']))
         else:

+ 408 - 0
main/zhihu_follow.py

@@ -1,3 +1,411 @@
 # -*- coding: utf-8 -*-
 # @Author: wangkun
 # @Time: 2022/10/31
+import os
+import sys
+import time
+import requests
+import urllib3
+sys.path.append(os.getcwd())
+from main.common import Common
+from main.feishu_lib import Feishu
+from main.follow_publish import Publish
+proxies = {'http': None, 'https': None}
+
+
+class ZhihuFollow:
+    offset = 0
+
+    @classmethod
+    def get_users_from_feishu(cls, log_type):
+        try:
+            user_sheet = Feishu.get_values_batch(log_type, 'zhihu', '4NTla6')
+            user_dict = {}
+            for i in range(1, len(user_sheet)):
+                user_name = user_sheet[i][0]
+                url_token = user_sheet[i][1]
+                referer = user_sheet[i][2]
+                our_id = user_sheet[i][3]
+                if user_name is None or url_token is None or our_id is None:
+                    pass
+                else:
+                    user_dict[user_name] = str(url_token) + ',' + str(referer) + ',' + str(our_id)
+            return user_dict
+        except Exception as e:
+            Common.logger(log_type).error('get_users_from_feishu异常:{}\n', e)
+
+    @classmethod
+    def get_follow_feeds(cls, log_type, url_token, referer, our_uid, env):
+        while True:
+            Common.logger(log_type).info('offset:{}', cls.offset)
+            url = "https://www.zhihu.com//api//v4//members//" + str(url_token) + "//zvideos?"
+            headers = {
+                'pragma': 'no-cache',
+                'cache-control': 'no-cache',
+                'x-zse-93': '101_3_3.0',
+                'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8',
+                'x-zst-81': '3_2.0aR_sn77yn6O92wOB8hPZnQr0EMYxc4f18wNBUgpTQ6nxERFZMRY0-4Lm-h3_tufIwJS8gcxTgJS_AuPZNcXCTwxI78YxEM20s4PGDwN8gGcYAupMWufIoLVqr4gxrRPOI0cY7HL8qun9g93mFukyigcmebS_FwOYPRP0E4rZUrN9DDom3hnynAUMnAVPF_PhaueTF7C89Uw8_w2YiDNBOcC_ggeL2HN1fTN0WvUq_UY9aCLBMQO0VvUfoTp9y9eTV4xC8b3YCGNs2bSfXwCZpUw06hcMJ_w0B8NmhvwMcGe9iqCZlcSftv3qTug_-BVqgwL1r7H99CeV24C9_Up9HqHmj9CsqUH8tBNLUbxm1gOprAO_6CL0Vg_z9DVs9rS1R9x08wxG2Cxme9FLlUc9jJu027gB3UVBJqpBbqUCrwo1nqHmggO_Nr9_BqcxfC2GnvSqNcxyIDOfiuw9dgCC27emaUpMxuVqquFYwUSL2BXs',
+                'accept': '*/*',
+                'referer': referer,
+                'sec-ch-ua': '"Chromium";v="106", "Google Chrome";v="106", "Not;A=Brand";v="99"',
+                'sec-ch-ua-mobile': '?0',
+                'sec-ch-ua-platform': '"macOS"',
+                'sec-fetch-dest': 'empty',
+                'sec-fetch-mode': 'cors',
+                'sec-fetch-site': 'same-origin',
+                'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36',
+                'x-ab-pb': 'CsIBCAAbAD8ARwC0AGkBagF0ATsCzALXAtgCTwNQA6ADoQOiA7cD8wP0AzMEjASNBKYE1gQRBVEFiwWMBZ4FMAYxBusGJwd3B3gH2AfcB90HZwh0CHYIeQjaCD8JQglgCY0JwwnECcUJxgnHCcgJyQnKCcsJzAnRCfQJBApJCmUKawqYCqUKqQq+CsQK1ArdCu0K/Qr+CjsLPAtDC0YLcQt2C4ULhwuNC8AL1wvgC+UL5gssDDgMcQyPDKwMuQzDDMkM+AwSYQEAAAAAAAAAAAMAAAAAAAAAAAAAAAQEAAQAAAAAAQAAAQAAAAACAgQAAAYAAAEBAAAAAAAAAAAAAAAAAwAAAAABAAAAAQEAAAAAAQABAAAAAAAFAAIBAAAGAgYAAAECAAA=',
+                'x-requested-with': 'fetch',
+                'accept-encoding': 'gzip, deflate, br',
+                'x-zse-96': '2.0_wSyMHDQ7MZYfDZWRCM=Il3PaIuFuaTZf=spPXrAiJo83rlG65AU+b6IIBIr5nJ5L',
+            }
+            params = {
+                'offset': str(cls.offset),
+                'limit': '20',
+                'similar_aggregation': True,
+                'include': 'similar_zvideo,creation_relationship',
+            }
+            cookies = {
+                '_zap': 'a17e5882-775f-49dd-b541-e854c0299999',
+                'd_c0': '"AFAcR4hr0RKPTn2-RL935cm51KQZn9-Xlb0=|1616071586"',
+                '_9755xjdesxxd_': '32',
+                'YD00517437729195%3AWM_TID': 'yR6Kt%2FwMI2xEFEQRVBYrou2J%2F14yfdzt',
+                'q_c1': '947ece3f1ccd4ccd83b718c113fe3935|1658911548000|1658911548000',
+                '_xsrf': 'cAM8ovVh43f0oJE2erl6ho8Y4CTZhFKF',
+                '__snaker__id': 'mqTPtP3IwbuoHA2K',
+                'gdxidpyhxdE': 'a2d%2FeD%2BEUNxnnTaLDjQfd28sI39g3pnKAqS%2BmodWMqYcMa3AMzV5eom2APR2z5rDHAVvfubp%2BWEzkcxdb9UjWNT0gbshTpBmHzU1%2BMB%2BfW5sAAUz1%5CTWIWbP34z7SV4TCB%2BfbQtoAdRAZANzEbcollrLlPmyAG%2FtPICs5ewAvswneclw%3A1666061422009',
+                'YD00517437729195%3AWM_NI': 'bTzKLUbqXTrTGVFS91056cj27L%2F9PQ8MG8ofPHnJc98014ktS5xa09N8yJZho7jEeQfeueH0sJLDH5YmaA2nCP1kQ1jaB4FChGGNA7HbM%2B5yRCuYOmGjfIs5LOdoxm1WSHY%3D',
+                'YD00517437729195%3AWM_NIKE': '9ca17ae2e6ffcda170e2e6eeb2f5628de7a5b2db5cfc8e8eb6d85f929e8aacc150b6ed9bd8b33c93afc089cf2af0fea7c3b92aa28cb6accf5fa2af98b5f160858a8ab4bc3bf4ebfa84e93af594e1dad35bfc9389d9ee6e9498a2abe233fcf0ffd5ea8091ebb882b3338ee8b7abd964ade9a6a6e85ba6bbbb86cb3cb19684a5cb3f9bb3afa2b1668190ff8cd43baabf8ed5c549ac9989afc43d8cbe83ccb873929dbbbace6785b6aaaaf23f9091ac90fb67f3899da9dc37e2a3',
+                'captcha_ticket_v2': '2|1:0|10:1666060537|17:captcha_ticket_v2|704:eyJ2YWxpZGF0ZSI6IkNOMzFfVkk0TmhfRVJ1SGxhQW4yV0ZHWFlXTjdIWXM3TnZQSUFMY19MRGdVV1dMX3Vody0wMFAtYnA0UXBFVnI5akI1NFNVajhZVEpLeXVLODJWajJoVU83MnBya2xyLi5TalExekwyZ3hQU3JjZTI4TkJweTh2NEg5QjFyVUlBME1zSGtfUlRqQ3lDd1BkQ2Y3c3J3WWl0V0Qyci5FTWV6eEJRMUdQcGlWS2dCXzRkQzhSWmNMT1ZmWnlxUDZWbTh6ZEdDdmVnVkhFTTFGVWNpNVJRV2NWLjZ6V2V4UUpJOWJibUdRZHpJQ0VQUFlZZU5ObVBKOTlKMUw1OWFxUmRxUzVtY1hDbXBsRzVBTnM0LmEyS1BDRGNTYWVTWUlpMFdfc0JlTE44QlZCXzFkWjFLV2xoUmx3bkR6QjJMdUdOcm1IRXRaejQ2T0ViVzhVS3ZSNjU2YUJEUk9tYUNscVM5cDk2T2cwY1JadlhEZFZOSlFSeG0wNkRUMEs5cHRLLS1hajFWaWtEMnp4UU50MEpFZE9PRGs2RWtqdklnWnM0S0s0bUVBd0tGS2FIMklJaXVod1dMck9WOGdKLUpwNjlYNU9hWWxNcEtCbk9pU2JYNUJfUnBmeU1hLlAwbUlBYXYwbnBvY0xRWmdMMXJpelN5OFVaVl9QMXduWTByR1BtMyJ9|557dafa54cac0a5cd55b3e8ebbb626e6817010e985c2a3c60a82fb00bcb8b72a',
+                'captcha_session_v2': '2|1:0|10:1666060537|18:captcha_session_v2|88:SUlnbE5uR29rUC83Z0VvWVpjTS9JV3VKSFFYTUl4T1hFbVdZZnB2Wms1Z1cxYkZFQndYWHhqVDRGWEE0NzVaTQ==|a40c62b74a94ad618205342e3f87091b525a50fe9c8f153af02b08a3569fa7c0',
+                'z_c0': '2|1:0|10:1666767387|4:z_c0|92:Mi4xVFdsTlB3QUFBQUFBVUJ4SGlHdlJFaVlBQUFCZ0FsVk5CVjg3WkFBOTBXb185c2wyUjJ6ZmQ1OTYtamliYWJWTUp3|abd71d40da50ae308430e26ce358d34cd4bccdfe575bf544d212019c7189ecdb',
+                'Hm_lvt_98beee57fd2ef70ccdd5ca52b9740c49': '1665574748,1666678329,1667194593',
+                'SESSIONID': 'hyrUgL9IzongRfviGSTmGR2sDyVliSwHuWy0fXouVk7',
+                'JOID': 'W14WBkoyfRA9faU0WD7qwUz2wuJAVQFkbBLmCBdAHXtcK8tNNNogTVJ6rzdabb3cImOxRThXGFkflrdU1CD0UWI=',
+                'osd': 'U10VAU46fhM6ea03WznuyU_1xeZIVgJjaBrlCxBEFXhfLM9FN9knSVp5rDBeZb7fJWe5RjtQHFEclbBQ3CP3VmY=',
+                'tst': 'v',
+                'NOT_UNREGISTER_WAITING': '1',
+                'Hm_lpvt_98beee57fd2ef70ccdd5ca52b9740c49': '1667373061',
+                'unlock_ticket': 'AGBWwkpQuhUmAAAAYAJVTQ0fYmOTbjeHqRp3XiDPD3ZVB5KkeaEeYw==',
+                'KLBRSID': '031b5396d5ab406499e2ac6fe1bb1a43|1667373074|1667370552',
+            }
+
+            urllib3.disable_warnings()
+            response = requests.get(url=url, headers=headers, params=params, cookies=cookies, verify=False, proxies=proxies)
+            cls.offset += 20
+            if 'data' not in response.json():
+                Common.logger(log_type).error('response:{}\n', response.text)
+            elif len(response.json()['data']) == 0:
+                Common.logger(log_type).error('response:{}\n', response.text)
+            else:
+                feeds = response.json()['data']
+                is_end = response.json()['paging']['is_end']
+                for i in range(len(feeds)):
+                    # video_title
+                    if 'title' not in feeds[i]:
+                        video_title = 0
+                    else:
+                        video_title = feeds[i]['title']
+
+                    # video_id
+                    if 'video' not in feeds[i]:
+                        video_id = 0
+                    elif 'video_id' not in feeds[i]['video']:
+                        video_id = 0
+                    else:
+                        video_id = feeds[i]['video']['video_id']
+
+                    # play_cnt
+                    if 'play_count' not in feeds[i]:
+                        play_cnt = 0
+                    else:
+                        play_cnt = feeds[i]['play_count']
+
+                    # comment_cnt
+                    if 'comment_count' not in feeds[i]:
+                        comment_cnt = 0
+                    else:
+                        comment_cnt = feeds[i]['comment_count']
+
+                    # like_cnt
+                    if 'liked_count' not in feeds[i]:
+                        like_cnt = 0
+                    else:
+                        like_cnt = feeds[i]['liked_count']
+
+                    # share_cnt
+                    if 'share_count' not in feeds[i]:
+                        share_cnt = 0
+                    else:
+                        share_cnt = feeds[i]['share_count']
+
+                    # voteup_cnt 赞同数
+                    if 'voteup_count' not in feeds[i]:
+                        voteup_cnt = 0
+                    else:
+                        voteup_cnt = feeds[i]['voteup_count']
+
+                    # publish_time
+                    if 'published_at' not in feeds[i]:
+                        publish_time = 0
+                    else:
+                        publish_time = feeds[i]['published_at']
+
+                    # duration
+                    if 'video' not in feeds[i]:
+                        duration = 0
+                    elif 'duration' not in feeds[i]['video']:
+                        duration = 0
+                    else:
+                        duration = feeds[i]['video']['duration']
+
+                    # width / height / video_url
+                    if 'video' not in feeds[i]:
+                        video_width = 0
+                        video_height = 0
+                        video_url = 0
+                    elif 'playlist' in feeds[i]['video'] and 'fhd' in feeds[i]['video']['playlist'] \
+                            and 'width' in feeds[i]['video']['playlist']['fhd'] \
+                            and 'height' in feeds[i]['video']['playlist']['fhd'] \
+                            and 'play_url' in feeds[i]['video']['playlist']['fhd']:
+                        video_width = feeds[i]['video']['playlist']['fhd']['width']
+                        video_height = feeds[i]['video']['playlist']['fhd']['height']
+                        video_url = feeds[i]['video']['playlist']['fhd']['play_url']
+                    elif 'playlist' in feeds[i]['video'] and 'fhd' in feeds[i]['video']['playlist'] \
+                            and 'width' in feeds[i]['video']['playlist']['fhd'] \
+                            and 'height' in feeds[i]['video']['playlist']['fhd'] \
+                            and 'url' in feeds[i]['video']['playlist']['fhd']:
+                        video_width = feeds[i]['video']['playlist']['fhd']['width']
+                        video_height = feeds[i]['video']['playlist']['fhd']['height']
+                        video_url = feeds[i]['video']['playlist']['fhd']['url']
+                    elif 'playlist' in feeds[i]['video'] and 'hd' in feeds[i]['video']['playlist'] \
+                            and 'width' in feeds[i]['video']['playlist']['hd'] \
+                            and 'height' in feeds[i]['video']['playlist']['hd'] \
+                            and 'play_url' in feeds[i]['video']['playlist']['hd']:
+                        video_width = feeds[i]['video']['playlist']['hd']['width']
+                        video_height = feeds[i]['video']['playlist']['hd']['height']
+                        video_url = feeds[i]['video']['playlist']['hd']['play_url']
+                    elif 'playlist' in feeds[i]['video'] and 'hd' in feeds[i]['video']['playlist'] \
+                            and 'width' in feeds[i]['video']['playlist']['hd'] \
+                            and 'height' in feeds[i]['video']['playlist']['hd'] \
+                            and 'url' in feeds[i]['video']['playlist']['hd']:
+                        video_width = feeds[i]['video']['playlist']['hd']['width']
+                        video_height = feeds[i]['video']['playlist']['hd']['height']
+                        video_url = feeds[i]['video']['playlist']['hd']['url']
+                    elif 'playlist' in feeds[i]['video'] and 'ld' in feeds[i]['video']['playlist'] \
+                            and 'width' in feeds[i]['video']['playlist']['ld'] \
+                            and 'height' in feeds[i]['video']['playlist']['ld'] \
+                            and 'play_url' in feeds[i]['video']['playlist']['ld']:
+                        video_width = feeds[i]['video']['playlist']['ld']['width']
+                        video_height = feeds[i]['video']['playlist']['ld']['height']
+                        video_url = feeds[i]['video']['playlist']['ld']['play_url']
+                    elif 'playlist' in feeds[i]['video'] and 'ld' in feeds[i]['video']['playlist'] \
+                            and 'width' in feeds[i]['video']['playlist']['ld'] \
+                            and 'height' in feeds[i]['video']['playlist']['ld'] \
+                            and 'url' in feeds[i]['video']['playlist']['ld']:
+                        video_width = feeds[i]['video']['playlist']['ld']['width']
+                        video_height = feeds[i]['video']['playlist']['ld']['height']
+                        video_url = feeds[i]['video']['playlist']['ld']['url']
+                    elif 'playlist' in feeds[i]['video'] and 'sd' in feeds[i]['video']['playlist'] \
+                            and 'width' in feeds[i]['video']['playlist']['sd'] \
+                            and 'height' in feeds[i]['video']['playlist']['sd'] \
+                            and 'play_url' in feeds[i]['video']['playlist']['sd']:
+                        video_width = feeds[i]['video']['playlist']['sd']['width']
+                        video_height = feeds[i]['video']['playlist']['sd']['height']
+                        video_url = feeds[i]['video']['playlist']['sd']['play_url']
+                    elif 'playlist' in feeds[i]['video'] and 'sd' in feeds[i]['video']['playlist'] \
+                            and 'width' in feeds[i]['video']['playlist']['sd'] \
+                            and 'height' in feeds[i]['video']['playlist']['sd'] \
+                            and 'url' in feeds[i]['video']['playlist']['sd']:
+                        video_width = feeds[i]['video']['playlist']['sd']['width']
+                        video_height = feeds[i]['video']['playlist']['sd']['height']
+                        video_url = feeds[i]['video']['playlist']['sd']['url']
+
+                    elif 'playlist_v2' in feeds[i]['video'] and 'fhd' in feeds[i]['video']['playlist_v2'] \
+                            and 'width' in feeds[i]['video']['playlist_v2']['fhd'] \
+                            and 'height' in feeds[i]['video']['playlist_v2']['fhd'] \
+                            and 'play_url' in feeds[i]['video']['playlist_v2']['fhd']:
+                        video_width = feeds[i]['video']['playlist_v2']['fhd']['width']
+                        video_height = feeds[i]['video']['playlist_v2']['fhd']['height']
+                        video_url = feeds[i]['video']['playlist_v2']['fhd']['play_url']
+                    elif 'playlist_v2' in feeds[i]['video'] and 'fhd' in feeds[i]['video']['playlist_v2'] \
+                            and 'width' in feeds[i]['video']['playlist_v2']['fhd'] \
+                            and 'height' in feeds[i]['video']['playlist_v2']['fhd'] \
+                            and 'url' in feeds[i]['video']['playlist_v2']['fhd']:
+                        video_width = feeds[i]['video']['playlist_v2']['fhd']['width']
+                        video_height = feeds[i]['video']['playlist_v2']['fhd']['height']
+                        video_url = feeds[i]['video']['playlist_v2']['fhd']['url']
+                    elif 'playlist_v2' in feeds[i]['video'] and 'hd' in feeds[i]['video']['playlist_v2'] \
+                            and 'width' in feeds[i]['video']['playlist_v2']['hd'] \
+                            and 'height' in feeds[i]['video']['playlist_v2']['hd'] \
+                            and 'play_url' in feeds[i]['video']['playlist_v2']['hd']:
+                        video_width = feeds[i]['video']['playlist_v2']['hd']['width']
+                        video_height = feeds[i]['video']['playlist_v2']['hd']['height']
+                        video_url = feeds[i]['video']['playlist_v2']['hd']['play_url']
+                    elif 'playlist_v2' in feeds[i]['video'] and 'hd' in feeds[i]['video']['playlist_v2'] \
+                            and 'width' in feeds[i]['video']['playlist_v2']['hd'] \
+                            and 'height' in feeds[i]['video']['playlist_v2']['hd'] \
+                            and 'url' in feeds[i]['video']['playlist_v2']['hd']:
+                        video_width = feeds[i]['video']['playlist_v2']['hd']['width']
+                        video_height = feeds[i]['video']['playlist_v2']['hd']['height']
+                        video_url = feeds[i]['video']['playlist_v2']['hd']['url']
+                    elif 'playlist_v2' in feeds[i]['video'] and 'ld' in feeds[i]['video']['playlist_v2'] \
+                            and 'width' in feeds[i]['video']['playlist_v2']['ld'] \
+                            and 'height' in feeds[i]['video']['playlist_v2']['ld'] \
+                            and 'play_url' in feeds[i]['video']['playlist_v2']['ld']:
+                        video_width = feeds[i]['video']['playlist_v2']['ld']['width']
+                        video_height = feeds[i]['video']['playlist_v2']['ld']['height']
+                        video_url = feeds[i]['video']['playlist_v2']['ld']['play_url']
+                    elif 'playlist_v2' in feeds[i]['video'] and 'ld' in feeds[i]['video']['playlist_v2'] \
+                            and 'width' in feeds[i]['video']['playlist_v2']['ld'] \
+                            and 'height' in feeds[i]['video']['playlist_v2']['ld'] \
+                            and 'url' in feeds[i]['video']['playlist_v2']['ld']:
+                        video_width = feeds[i]['video']['playlist_v2']['ld']['width']
+                        video_height = feeds[i]['video']['playlist_v2']['ld']['height']
+                        video_url = feeds[i]['video']['playlist_v2']['ld']['url']
+                    elif 'playlist_v2' in feeds[i]['video'] and 'sd' in feeds[i]['video']['playlist_v2'] \
+                            and 'width' in feeds[i]['video']['playlist_v2']['sd'] \
+                            and 'height' in feeds[i]['video']['playlist_v2']['sd'] \
+                            and 'play_url' in feeds[i]['video']['playlist_v2']['sd']:
+                        video_width = feeds[i]['video']['playlist_v2']['sd']['width']
+                        video_height = feeds[i]['video']['playlist_v2']['sd']['height']
+                        video_url = feeds[i]['video']['playlist_v2']['sd']['play_url']
+                    elif 'playlist_v2' in feeds[i]['video'] and 'sd' in feeds[i]['video']['playlist_v2'] \
+                            and 'width' in feeds[i]['video']['playlist_v2']['sd'] \
+                            and 'height' in feeds[i]['video']['playlist_v2']['sd'] \
+                            and 'url' in feeds[i]['video']['playlist_v2']['sd']:
+                        video_width = feeds[i]['video']['playlist_v2']['sd']['width']
+                        video_height = feeds[i]['video']['playlist_v2']['sd']['height']
+                        video_url = feeds[i]['video']['playlist_v2']['sd']['url']
+                    else:
+                        video_width = 0
+                        video_height = 0
+                        video_url = 0
+
+                    # cover_url
+                    if 'video' not in feeds[i]:
+                        cover_url = 0
+                    elif 'thumbnail' not in feeds[i]['video']:
+                        cover_url = 0
+                    else:
+                        cover_url = feeds[i]['video']['thumbnail']
+
+                    # user_name / uid / user_type / url_token / avatar_url
+                    if 'author' not in feeds[i]:
+                        user_name = 0
+                        uid = 0
+                        user_type = 0
+                        url_token = 0
+                        avatar_url = 0
+                    elif 'author' in feeds[i] \
+                            and 'name' in feeds[i]['author'] \
+                            and 'uid' in feeds[i]['author'] \
+                            and 'user_type' in feeds[i]['author'] \
+                            and 'url_token' in feeds[i]['author'] \
+                            and 'avatar_url_template' in feeds[i]['author']:
+                        user_name = feeds[i]['author']['name']
+                        uid = feeds[i]['author']['uid']
+                        user_type = feeds[i]['author']['user_type']
+                        url_token = feeds[i]['author']['url_token']
+                        avatar_url = feeds[i]['author']['avatar_url_template']
+                    elif 'author' in feeds[i] \
+                            and 'name' in feeds[i]['author'] \
+                            and 'uid' in feeds[i]['author'] \
+                            and 'user_type' in feeds[i]['author'] \
+                            and 'url_token' in feeds[i]['author'] \
+                            and 'avatar_url' in feeds[i]['author']:
+                        user_name = feeds[i]['author']['name']
+                        uid = feeds[i]['author']['uid']
+                        user_type = feeds[i]['author']['user_type']
+                        url_token = feeds[i]['author']['url_token']
+                        avatar_url = feeds[i]['author']['avatar_url']
+                    else:
+                        user_name = 0
+                        uid = 0
+                        user_type = 0
+                        url_token = 0
+                        avatar_url = 0
+
+                    Common.logger(log_type).info('video_title:{}', video_title)
+                    Common.logger(log_type).info('duration:{}秒', int(duration))
+                    Common.logger(log_type).info(
+                        'publish_time:{}', time.strftime("%Y/%m/%d %H:%M:%S", time.localtime(publish_time)))
+
+                    if video_title == 0 or cover_url == 0 or video_url == 0:
+                        Common.logger(log_type).info('无效视频\n')
+                    elif int(time.time()) - int(publish_time) >= 3600*24*10:
+                        Common.logger(log_type).info('发布时间:{} 超过30天\n', time.strftime("%Y/%m/%d %H:%M:%S", time.localtime(publish_time)))
+                        cls.offset = 0
+                        return
+                    elif int(duration) < 60:
+                        Common.logger(log_type).info('时长{}<60秒\n', int(duration))
+                    elif str(video_id) in [x for y in Feishu.get_values_batch(log_type, 'zhihu', '8871e3') for x in y]:
+                        Common.logger(log_type).info('视频已下载\n')
+                    elif str(video_id) in [x for y in Feishu.get_values_batch(log_type, 'zhihu', '4MGuux') for x in y]:
+                        Common.logger(log_type).info('视频已下载\n')
+                    else:
+                        Common.download_method(log_type, 'cover', video_title, cover_url)
+                        Common.download_method(log_type, 'video', video_title, video_url)
+                        # 保存视频信息至 "./videos/{download_video_title}/info.txt"
+                        with open("./videos/" + video_title + "/" + "info.txt", "a", encoding="UTF-8") as f_a:
+                            f_a.write(str(video_id) + "\n" +
+                                      str(video_title) + "\n" +
+                                      str(int(duration)) + "\n" +
+                                      str(play_cnt) + "\n" +
+                                      str(comment_cnt) + "\n" +
+                                      str(like_cnt) + "\n" +
+                                      str(share_cnt) + "\n" +
+                                      str(video_width) + '*' + str(video_height) + "\n" +
+                                      str(publish_time) + "\n" +
+                                      str(user_name) + "\n" +
+                                      str(avatar_url) + "\n" +
+                                      str(video_url) + "\n" +
+                                      str(cover_url) + "\n" +
+                                      "zhihu_follow" + str(int(time.time())))
+                        Common.logger(log_type).info("==========视频信息已保存至info.txt==========")
+
+                        our_video_id = Publish.upload_and_publish(log_type, env, our_uid)
+                        if env == 'dev':
+                            our_video_link = "https://testadmin.piaoquantv.com/cms/post-detail/" + str(
+                                our_video_id) + "/info"
+                        else:
+                            our_video_link = "https://admin.piaoquantv.com/cms/post-detail/" + str(our_video_id) + "/info"
+                        Common.logger(log_type).info("视频上传完成:{}\n", video_title)
+
+                        Feishu.insert_columns(log_type, 'zhihu', '4MGuux', 'ROWS', 1, 2)
+                        time.sleep(1)
+                        upload_time = int(time.time())
+                        values = [[
+                            time.strftime("%Y/%m/%d %H:%M:%S", time.localtime(upload_time)),
+                            "定向榜",
+                            video_title,
+                            str(video_id),
+                            our_video_link,
+                            play_cnt,
+                            comment_cnt,
+                            like_cnt,
+                            share_cnt,
+                            voteup_cnt,
+                            int(duration),
+                            str(video_width) + '*' + str(video_height),
+                            time.strftime("%Y/%m/%d %H:%M:%S", time.localtime(int(publish_time))),
+                            user_name,
+                            uid,
+                            'https://www.zhihu.com/' + user_type + '/' + url_token,
+                            user_type,
+                            url_token,
+                            avatar_url,
+                            cover_url,
+                            video_url]]
+                        Feishu.update_values(log_type, 'zhihu', "4MGuux", "F2:Z2", values)
+                        Common.logger(log_type).info("视频已保存至云文档:{}\n", video_title)
+
+                if is_end is True:
+                    Common.logger(log_type).info('到底了\n')
+                    cls.offset = 0
+                    return
+
+
+if __name__ == '__main__':
+    ZhihuFollow.get_follow_feeds('follow', 'lindsayzou', 'https://www.zhihu.com/people/lindsayzou/zvideos', '6267140', 'dev')
+    # ZhihuFollow.get_follow_feeds('follow', 'lao-ba-ping-ce', 'https://www.zhihu.com/org/lao-ba-ping-ce/zvideos', '6267140', 'dev')

+ 2 - 2
main/zhihu_hot.py

@@ -24,8 +24,8 @@ class ZhihuHot:
         - 站内标题=知乎 视频原标题
         - 站内封面图=知乎 视频原封面图
         """
-        if int(time.time()) - publish_time <= 3600*24*30:
-            if int(play_cnt) >= 10000:
+        if int(time.time()) - publish_time <= 3600*24*180:
+            if int(play_cnt) >= 30000:
                 if int(duration) >= 60:
                     return True
                 else: