2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
13 class YandexVideoIE(InfoExtractor
):
17 yandex\.ru(?:/(?:portal/(?:video|efir)|efir))?/?\?.*?stream_id=|
18 frontend\.vh\.yandex\.ru/player/
20 (?P<id>(?:[\da-f]{32}|[\w-]{12}))
23 'url': 'https://yandex.ru/portal/video?stream_id=4dbb36ec4e0526d58f9f2dc8f0ecf374',
24 'md5': 'e02a05bfaf0d9615ef07ae3a10f4faf4',
26 'id': '4dbb36ec4e0526d58f9f2dc8f0ecf374',
28 'title': 'Русский Вудсток - главный рок-фест в истории СССР / вДудь',
29 'description': 'md5:7d6b8d4bc4a3b9a56499916c1ea5b5fa',
30 'thumbnail': r
're:^https?://',
31 'timestamp': 1549972939,
34 'upload_date': '20190212',
40 'url': 'https://yandex.ru/portal/efir?stream_id=4dbb262b4fe5cf15a215de4f34eee34d&from=morda',
41 'only_matching': True,
43 'url': 'https://yandex.ru/?stream_id=4dbb262b4fe5cf15a215de4f34eee34d',
44 'only_matching': True,
46 'url': 'https://frontend.vh.yandex.ru/player/4dbb262b4fe5cf15a215de4f34eee34d?from=morda',
47 'only_matching': True,
49 # vod-episode, series episode
50 'url': 'https://yandex.ru/portal/video?stream_id=45b11db6e4b68797919c93751a938cee',
51 'only_matching': True,
54 'url': 'https://yandex.ru/?stream_channel=1538487871&stream_id=4132a07f71fb0396be93d74b3477131d',
55 'only_matching': True,
58 'url': 'https://yandex.ru/portal/video?from=morda&stream_id=485a92d94518d73a9d0ff778e13505f8',
59 'only_matching': True,
61 'url': 'https://yandex.ru/efir?stream_active=watching&stream_id=v7a2dZ-v5mSI&from_block=efir_newtab',
62 'only_matching': True,
65 def _real_extract(self
, url
):
66 video_id
= self
._match
_id
(url
)
68 player
= try_get((self
._download
_json
(
69 'https://frontend.vh.yandex.ru/graphql', video_id
, data
=('''{
70 player(content_id: "%s") {
89 }''' % video_id
).encode(), fatal
=False)), lambda x
: x
['player']['content'])
90 if not player
or player
.get('error'):
91 player
= self
._download
_json
(
92 'https://frontend.vh.yandex.ru/v23/player/%s.json' % video_id
,
94 'stream_options': 'hires',
95 'disable_trackings': 1,
97 content
= player
['content']
99 title
= content
.get('title') or content
['computed_title']
102 streams
= content
.get('streams') or []
103 streams
.append({'url': content.get('content_url')}
)
104 for stream
in streams
:
105 content_url
= url_or_none(stream
.get('url'))
108 ext
= determine_ext(content_url
)
112 formats
.extend(self
._extract
_m
3u8_formats
(
113 content_url
, video_id
, 'mp4',
114 'm3u8_native', m3u8_id
='hls', fatal
=False))
116 formats
.extend(self
._extract
_mpd
_formats
(
117 content_url
, video_id
, mpd_id
='dash', fatal
=False))
119 formats
.append({'url': content_url}
)
121 self
._sort
_formats
(formats
)
123 timestamp
= (int_or_none(content
.get('release_date'))
124 or int_or_none(content
.get('release_date_ut'))
125 or int_or_none(content
.get('start_time')))
126 season
= content
.get('season') or {}
131 'description': content
.get('description'),
132 'thumbnail': content
.get('thumbnail'),
133 'timestamp': timestamp
,
134 'duration': int_or_none(content
.get('duration')),
135 'series': content
.get('program_title'),
136 'age_limit': int_or_none(content
.get('restriction_age')),
137 'view_count': int_or_none(content
.get('views_count')),
138 'like_count': int_or_none(content
.get('likes')),
139 'dislike_count': int_or_none(content
.get('dislikes')),
140 'season_number': int_or_none(season
.get('season_number')),
141 'season_id': season
.get('id'),
142 'release_year': int_or_none(content
.get('release_year')),