2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
10 compat_urllib_parse_urlparse
,
17 class VideomoreBaseIE(InfoExtractor
):
18 _API_BASE_URL
= 'https://more.tv/api/v3/web/'
19 _VALID_URL_BASE
= r
'https?://(?:videomore\.ru|more\.tv)/'
21 def _download_page_data(self
, display_id
):
22 return self
._download
_json
(
23 self
._API
_BASE
_URL
+ 'PageData', display_id
, query
={
24 'url': '/' + display_id
,
25 })['attributes']['response']['data']
27 def _track_url_result(self
, track
):
28 track_vod
= track
['trackVod']
29 video_url
= track_vod
.get('playerLink') or track_vod
['link']
30 return self
.url_result(
31 video_url
, VideomoreIE
.ie_key(), track_vod
.get('hubId'))
34 class VideomoreIE(InfoExtractor
):
37 videomore:(?P<sid>\d+)$|
46 (?:player\.)?videomore\.ru|
47 siren\.more\.tv/player
48 )/[^/]*\?.*?\btrack_id=|
49 odysseus\.more.tv/player/(?P<partner_id>\d+)/
52 (?:[/?#&]|\.(?:xml|json)|$)
55 'url': 'http://videomore.ru/kino_v_detalayah/5_sezon/367617',
56 'md5': '44455a346edc0d509ac5b5a5b531dc35',
60 'title': 'Кино в деталях 5 сезон В гостях Алексей Чумаков и Юлия Ковальчук',
61 'series': 'Кино в деталях',
62 'episode': 'В гостях Алексей Чумаков и Юлия Ковальчук',
63 'thumbnail': r
're:^https?://.*\.jpg',
69 'skip': 'The video is not available for viewing.',
71 'url': 'http://videomore.ru/embed/259974',
75 'title': 'Молодежка 2 сезон 40 серия',
76 'series': 'Молодежка',
78 'episode': '40 серия',
79 'thumbnail': r
're:^https?://.*\.jpg',
85 'skip_download': True,
88 'url': 'http://videomore.ru/molodezhka/sezon_promo/341073',
92 'title': 'Промо Команда проиграла из-за Бакина?',
93 'episode': 'Команда проиграла из-за Бакина?',
94 'thumbnail': r
're:^https?://.*\.jpg',
100 'skip_download': True,
102 'skip': 'The video is not available for viewing.',
104 'url': 'http://videomore.ru/elki_3?track_id=364623',
105 'only_matching': True,
107 'url': 'http://videomore.ru/embed/364623',
108 'only_matching': True,
110 'url': 'http://videomore.ru/video/tracks/364623.xml',
111 'only_matching': True,
113 'url': 'http://videomore.ru/video/tracks/364623.json',
114 'only_matching': True,
116 'url': 'http://videomore.ru/video/tracks/158031/quotes/33248',
117 'only_matching': True,
119 'url': 'videomore:367617',
120 'only_matching': True,
122 'url': 'https://player.videomore.ru/?partner_id=97&track_id=736234&autoplay=0&userToken=',
123 'only_matching': True,
125 'url': 'https://odysseus.more.tv/player/1788/352317',
126 'only_matching': True,
128 'url': 'https://siren.more.tv/player/config?track_id=352317&partner_id=1788&user_token=',
129 'only_matching': True,
134 def _extract_url(webpage
):
136 r
'<object[^>]+data=(["\'])https?
://videomore\
.ru
/player\
.swf
\?.*config
=(?P
<url
>https?
://videomore\
.ru
/(?
:[^
/]+/)+\d
+\
.xml
).*\
1',
140 r'<iframe
[^
>]+src
=([\'"])(?P<url>https?://videomore\.ru/embed/\d+)',
144 return mobj.group('url')
146 def _real_extract(self, url):
147 mobj = re.match(self._VALID_URL, url)
148 video_id = mobj.group('sid') or mobj.group('id')
149 partner_id = mobj.group('partner_id') or compat_parse_qs(compat_urllib_parse_urlparse(url).query).get('partner_id', [None])[0] or '97'
151 item = self._download_json(
152 'https://siren.more.tv/player/config', video_id, query={
153 'partner_id': partner_id,
154 'track_id': video_id,
155 })['data']['playlist']['items'][0]
157 title = item.get('title')
158 series = item.get('project_name')
159 season = item.get('season_name')
160 episode = item.get('episode_name')
163 for v in (series, season, episode):
166 title = ' '.join(title)
168 streams = item.get('streams') or []
169 for protocol in ('DASH', 'HLS'):
170 stream_url = item.get(protocol.lower() + '_url')
172 streams.append({'protocol': protocol, 'url': stream_url})
175 for stream in streams:
176 stream_url = stream.get('url')
179 protocol = stream.get('protocol')
180 if protocol == 'DASH':
181 formats.extend(self._extract_mpd_formats(
182 stream_url, video_id, mpd_id='dash', fatal=False))
183 elif protocol == 'HLS':
184 formats.extend(self._extract_m3u8_formats(
185 stream_url, video_id, 'mp4', 'm3u8_native',
186 m3u8_id='hls', fatal=False))
187 elif protocol == 'MSS':
188 formats.extend(self._extract_ism_formats(
189 stream_url, video_id, ism_id='mss', fatal=False))
192 error = item.get('error')
194 if error in ('Данное видео недоступно для просмотра на территории этой страны', 'Данное видео доступно для просмотра только на территории России'):
195 self.raise_geo_restricted(countries=['RU'], metadata_available=True)
196 self.raise_no_formats(error, expected=True)
197 self._sort_formats(formats)
205 'thumbnail': item.get('thumbnail_url'),
206 'duration': int_or_none(item.get('duration')),
207 'view_count': int_or_none(item.get('views')),
208 'age_limit': int_or_none(item.get('min_age')),
213 class VideomoreVideoIE(VideomoreBaseIE):
214 IE_NAME = 'videomore:video'
215 _VALID_URL = VideomoreBaseIE._VALID_URL_BASE + r'(?P<id>(?:(?:[^/]+/){2})?[^/?#&]+)(?:/*|[?#&].*?)$'
217 # single video with og:video:iframe
218 'url': 'http://videomore.ru/elki_3',
224 'thumbnail': r're:^https?://.*\.jpg',
230 'skip_download': True,
232 'skip': 'Requires logging in',
234 # season single series with og:video:iframe
235 'url': 'http://videomore.ru/poslednii_ment/1_sezon/14_seriya',
239 'title': 'Последний мент 1 сезон 14 серия',
240 'series': 'Последний мент',
242 'episode': '14 серия',
243 'thumbnail': r're:^https?://.*\.jpg',
249 'skip_download': True,
252 'url': 'http://videomore.ru/sejchas_v_seti/serii_221-240/226_vypusk',
253 'only_matching': True,
255 # single video without og:video:iframe
256 'url': 'http://videomore.ru/marin_i_ego_druzya',
260 'title': '1 серия. Здравствуй, Аквавилль!',
261 'description': 'md5:c6003179538b5d353e7bcd5b1372b2d7',
262 'thumbnail': r're:^https?://.*\.jpg',
268 'skip_download': True,
270 'skip': 'redirects to https://more.tv/'
272 'url': 'https://videomore.ru/molodezhka/6_sezon/29_seriya?utm_so',
273 'only_matching': True,
275 'url': 'https://more.tv/poslednii_ment/1_sezon/14_seriya',
276 'only_matching': True,
280 def suitable(cls, url):
281 return False if VideomoreIE.suitable(url) else super(VideomoreVideoIE, cls).suitable(url)
283 def _real_extract(self, url):
284 display_id = self._match_id(url)
285 return self._track_url_result(self._download_page_data(display_id))
288 class VideomoreSeasonIE(VideomoreBaseIE):
289 IE_NAME = 'videomore:season'
290 _VALID_URL = VideomoreBaseIE._VALID_URL_BASE + r'(?!embed)(?P<id>[^/]+/[^/?#&]+)(?:/*|[?#&].*?)$'
292 'url': 'http://videomore.ru/molodezhka/film_o_filme',
294 'id': 'molodezhka/film_o_filme',
295 'title': 'Фильм о фильме',
297 'playlist_mincount': 3,
299 'url': 'http://videomore.ru/molodezhka/sezon_promo?utm_so',
300 'only_matching': True,
302 'url': 'https://more.tv/molodezhka/film_o_filme',
303 'only_matching': True,
307 def suitable(cls, url):
308 return (False if (VideomoreIE.suitable(url) or VideomoreVideoIE.suitable(url))
309 else super(VideomoreSeasonIE, cls).suitable(url))
311 def _real_extract(self, url):
312 display_id = self._match_id(url)
313 season = self._download_page_data(display_id)
314 season_id = compat_str(season['id'])
315 tracks = self._download_json(
316 self._API_BASE_URL + 'seasons/%s/tracks' % season_id,
320 entries.append(self._track_url_result(track))
321 return self.playlist_result(entries, display_id, season.get('title'))