123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373 |
- # -*- 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.hot_publish import Publish
- proxies = {'http': None, 'https': None}
- class ZhihuHot:
- @classmethod
- def download_rule(cls, publish_time, play_cnt, duration):
- """
- 热榜内容抓取
- - 发布时间<30天
- - 视频播放量>1w
- - 视频时长1分钟以上
- - 站内标题=知乎 视频原标题
- - 站内封面图=知乎 视频原封面图
- """
- if int(time.time()) - publish_time <= 3600*24*180:
- if int(play_cnt) >= 30000:
- if int(duration) >= 60:
- return True
- else:
- return False
- else:
- return False
- else:
- return False
- @classmethod
- def get_hot_feeds(cls, log_type, env):
- try:
- url = "https://www.zhihu.com/api/v4/zvideo-tabs/tabs/choice/feeds/recommend?include=creation_relationship&limit=12&offset=0&trans="
- payload = {}
- headers = {
- 'authority': 'www.zhihu.com',
- 'accept': '*/*',
- 'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8',
- 'cache-control': 'no-cache',
- 'cookie': '_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; NOT_UNREGISTER_WAITING=1; SESSIONID=hyrUgL9IzongRfviGSTmGR2sDyVliSwHuWy0fXouVk7; JOID=W14WBkoyfRA9faU0WD7qwUz2wuJAVQFkbBLmCBdAHXtcK8tNNNogTVJ6rzdabb3cImOxRThXGFkflrdU1CD0UWI=; osd=U10VAU46fhM6ea03WznuyU_1xeZIVgJjaBrlCxBEFXhfLM9FN9knSVp5rDBeZb7fJWe5RjtQHFEclbBQ3CP3VmY=; Hm_lpvt_98beee57fd2ef70ccdd5ca52b9740c49=1667194733; unlock_ticket=AGBWwkpQuhUmAAAAYAJVTXVmX2MFufvSl3EpQEP_SGhR4MLNWspWcg==; KLBRSID=975d56862ba86eb589d21e89c8d1e74e|1667194768|1667194592; tst=v; KLBRSID=c450def82e5863a200934bb67541d696|1667198865|1667198865',
- 'pragma': 'no-cache',
- 'referer': 'https://www.zhihu.com/zvideo',
- '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-param': '',
- 'x-ab-pb': 'CsIBCAAbAD8ARwC0AGkBagF0ATsCzALXAtgCTwNQA6ADoQOiA7cD8wP0AzMEjASNBKYE1gQRBVEFiwWMBZ4FMAYxBusGJwd3B3gH2AfcB90HZwh0CHYIeQjaCD8JQglgCY0JwwnECcUJxgnHCcgJyQnKCcsJzAnRCfQJBApJCmUKawqYCqUKqQq+CsQK1ArdCu0K/Qr+CjsLPAtDC0YLcQt2C4ULhwuNC8AL1wvgC+UL5gssDDgMcQyPDKwMuQzDDMkM+AwSYQEAAAAAAAAAAAMAAAAAAAAAAAAAAAQEAAQAAAAAAQAAAQAAAAACAgQAAAYAAAEBAAAAAAAAAAAAAAAAAwAAAAABAAAAAQEAAAAAAQABAAAAAAAFAAIBAAAGAgYAAAECAAA=',
- 'x-requested-with': 'fetch',
- 'x-zse-93': '101_3_3.0',
- 'x-zse-96': '2.0_R+OtKiiBAH8BqgSqnWa63n4TBlvKYA=Thp0Ii5Wi0zBYa0lGomcBURFe+QKOspjH',
- 'x-zst-81': '3_2.0aR_sn77yn6O92wOB8hPZnQr0EMYxc4f18wNBUgpTQ6nxERFZMRY0-4Lm-h3_tufIwJS8gcxTgJS_AuPZNcXCTwxI78YxEM20s4PGDwN8gGcYAupMWufIoLVqr4gxrRPOI0cY7HL8qun9g93mFukyigcmebS_FwOYPRP0E4rZUrN9DDom3hnynAUMnAVPF_PhaueTFer1OCV98Bx0YGCGTccLDrxsb9eM8Tc9JboLpgxVNhcBXvNKhquY3CwObUSTVHCmOguLtq2KPhxmhCH9TJpGahcpgGgf0GF81vH_XhopQBcLXJOyyrOyqrXYiUg9-hXKtBHMPwx_IGNCFDCB6JrVCgoVEDoCBRY8gr9YiBxpeLC_4uY0Cg_zFhtskRc_8Tg90Be8CBg8fu316gY8puOBoTSMNBXC8CYqxgVm3gtBPC28NCx18vN9xUO1AGFLZgNY3rVYHvHLQ4CC_B31aco0WJeYoHX10cPywJOCQXts'
- }
- urllib3.disable_warnings()
- response = requests.get(url, headers=headers, data=payload, verify=False, proxies=proxies)
- if 'data' not in response.json():
- Common.logger(log_type).error('response:{}', response.text)
- elif len(response.json()['data']) == 0:
- Common.logger(log_type).error('response:{}', response.text)
- else:
- feeds = response.json()['data']
- 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('play_cnt:{}', play_cnt)
- 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 video_id == 0 or avatar_url == 0 or video_url == 0:
- Common.logger(log_type).info('无效视频\n')
- elif cls.download_rule(publish_time, play_cnt, duration) is False:
- Common.logger(log_type).info('不满足下载规则\n')
- 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" + str(int(time.time())))
- Common.logger(log_type).info("==========视频信息已保存至info.txt==========")
- our_video_id = Publish.upload_and_publish(log_type, env, 'hot')
- 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', '8871e3', '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', "8871e3", "F2:Z2", values)
- Common.logger(log_type).info("视频已保存至云文档:{}\n", video_title)
- except Exception as e:
- Common.logger(log_type).error('get_hot_feeds异常:{}\n', e)
- if __name__ == '__main__':
- ZhihuHot.get_hot_feeds('hot', 'dev')
|