1 from .common
import InfoExtractor
2 from ..utils
import float_or_none
, format_field
, int_or_none
5 class ZhihuIE(InfoExtractor
):
6 _VALID_URL
= r
'https?://(?:www\.)?zhihu\.com/zvideo/(?P<id>[0-9]+)'
8 'url': 'https://www.zhihu.com/zvideo/1342930761977176064',
9 'md5': 'c8d4c9cd72dd58e6f9bc9c2c84266464',
11 'id': '1342930761977176064',
14 'thumbnail': r
're:^https?://.*\.jpg',
16 'timestamp': 1612959715,
17 'upload_date': '20210210',
18 'uploader_id': '244ecb13b0fd7daf92235288c8ca3365',
26 def _real_extract(self
, url
):
27 video_id
= self
._match
_id
(url
)
28 zvideo
= self
._download
_json
(
29 'https://www.zhihu.com/api/v4/zvideos/' + video_id
, video_id
)
30 title
= zvideo
['title']
31 video
= zvideo
.get('video') or {}
34 for format_id
, q
in (video
.get('playlist') or {}).items():
35 play_url
= q
.get('url') or q
.get('play_url')
39 'asr': int_or_none(q
.get('sample_rate')),
40 'filesize': int_or_none(q
.get('size')),
41 'format_id': format_id
,
42 'fps': int_or_none(q
.get('fps')),
43 'height': int_or_none(q
.get('height')),
44 'tbr': float_or_none(q
.get('bitrate')),
46 'width': int_or_none(q
.get('width')),
49 author
= zvideo
.get('author') or {}
50 url_token
= author
.get('url_token')
56 'thumbnail': video
.get('thumbnail') or zvideo
.get('image_url'),
57 'uploader': author
.get('name'),
58 'timestamp': int_or_none(zvideo
.get('published_at')),
59 'uploader_id': author
.get('id'),
60 'uploader_url': format_field(url_token
, None, 'https://www.zhihu.com/people/%s'),
61 'duration': float_or_none(video
.get('duration')),
62 'view_count': int_or_none(zvideo
.get('play_count')),
63 'like_count': int_or_none(zvideo
.get('liked_count')),
64 'comment_count': int_or_none(zvideo
.get('comment_count')),