2 from __future__ import unicode_literals
6 from .common import InfoExtractor
7 from ..utils import js_to_json
10 class SportBoxEmbedIE(InfoExtractor):
11 _VALID_URL = r'https?://news\.sportbox\.ru/vdl/player(?:/[^/]+/|\?.*?\bn?id=)(?P<id>\d+)'
13 'url': 'http://news.sportbox.ru/vdl/player/ci/211355',
17 'title': 'В Новороссийске прошел детский турнир «Поле славы боевой»',
18 'thumbnail': r're:^https?://.*\.jpg$',
22 'skip_download': True,
25 'url': 'http://news.sportbox.ru/vdl/player?nid=370908&only_player=1&autostart=false&playeri=2&height=340&width=580',
26 'only_matching': True,
30 def _extract_urls(webpage):
32 r'<iframe[^>]+src="(https?://news\.sportbox\.ru/vdl/player[^"]+)"',
35 def _real_extract(self, url):
36 video_id = self._match_id(url)
38 webpage = self._download_webpage(url, video_id)
43 # desktop_advert_config contains complex Javascripts and we don't need it
44 return js_to_json(re.sub(r'desktop_advert_config.*', '', code))
46 jwplayer_data = self._parse_json(self._search_regex(
47 r'(?s)player\.setup\(({.+?})\);', webpage, 'jwplayer settings'), video_id,
48 transform_source=cleanup_js)
50 hls_url = jwplayer_data.get('hls_url')
52 formats.extend(self._extract_m3u8_formats(
53 hls_url, video_id, ext='mp4', m3u8_id='hls'))
55 rtsp_url = jwplayer_data.get('rtsp_url')
62 self._sort_formats(formats)
64 title = jwplayer_data['node_title']
65 thumbnail = jwplayer_data.get('image_url')
70 'thumbnail': thumbnail,