2 from __future__ import unicode_literals
6 from .common import InfoExtractor
7 from ..compat import compat_urlparse
14 class SportBoxIE(InfoExtractor):
15 _VALID_URL = r'https?://news\.sportbox\.ru/(?:[^/]+/)+spbvideo_NI\d+_(?P<display_id>.+)'
17 'url': 'http://news.sportbox.ru/Vidy_sporta/Avtosport/Rossijskij/spbvideo_NI483529_Gonka-2-zaezd-Obyedinenniy-2000-klassi-Turing-i-S',
18 'md5': 'ff56a598c2cf411a9a38a69709e97079',
22 'title': 'Гонка 2 заезд ««Объединенный 2000»: классы Туринг и Супер-продакшн',
23 'description': 'md5:3d72dc4a006ab6805d82f037fdc637ad',
24 'thumbnail': 're:^https?://.*\.jpg$',
25 'upload_date': '20140928',
29 'skip_download': True,
32 'url': 'http://news.sportbox.ru/Vidy_sporta/billiard/spbvideo_NI486287_CHempionat-mira-po-dinamichnoy-piramide-4',
33 'only_matching': True,
35 'url': 'http://news.sportbox.ru/video/no_ads/spbvideo_NI536574_V_Novorossijske_proshel_detskij_turnir_Pole_slavy_bojevoj?ci=211355',
36 'only_matching': True,
39 def _real_extract(self, url):
40 mobj = re.match(self._VALID_URL, url)
41 display_id = mobj.group('display_id')
43 webpage = self._download_webpage(url, display_id)
45 player = self._search_regex(
46 r'src="/?(vdl/player/[^"]+)"', webpage, 'player')
48 title = self._html_search_regex(
49 [r'"nodetitle"\s*:\s*"([^"]+)"', r'class="node-header_{1,2}title">([^<]+)'],
51 description = self._og_search_description(webpage) or self._html_search_meta(
52 'description', webpage, 'description')
53 thumbnail = self._og_search_thumbnail(webpage)
54 upload_date = unified_strdate(self._html_search_meta(
55 'dateCreated', webpage, 'upload date'))
58 '_type': 'url_transparent',
59 'url': compat_urlparse.urljoin(url, '/%s' % player),
60 'display_id': display_id,
62 'description': description,
63 'thumbnail': thumbnail,
64 'upload_date': upload_date,
68 class SportBoxEmbedIE(InfoExtractor):
69 _VALID_URL = r'https?://news\.sportbox\.ru/vdl/player(?:/[^/]+/|\?.*?\bn?id=)(?P<id>\d+)'
71 'url': 'http://news.sportbox.ru/vdl/player/ci/211355',
75 'title': 'В Новороссийске прошел детский турнир «Поле славы боевой»',
76 'thumbnail': 're:^https?://.*\.jpg$',
80 'skip_download': True,
83 'url': 'http://news.sportbox.ru/vdl/player?nid=370908&only_player=1&autostart=false&playeri=2&height=340&width=580',
84 'only_matching': True,
88 def _extract_urls(webpage):
90 r'<iframe[^>]+src="(https?://news\.sportbox\.ru/vdl/player[^"]+)"',
93 def _real_extract(self, url):
94 video_id = self._match_id(url)
96 webpage = self._download_webpage(url, video_id)
98 hls = self._search_regex(
99 r"sportboxPlayer\.jwplayer_common_params\.file\s*=\s*['\"]([^'\"]+)['\"]",
102 formats = self._extract_m3u8_formats(hls, video_id, 'mp4')
104 title = self._search_regex(
105 r'sportboxPlayer\.node_title\s*=\s*"([^"]+)"', webpage, 'title')
107 thumbnail = self._search_regex(
108 r'sportboxPlayer\.jwplayer_common_params\.image\s*=\s*"([^"]+)"',
109 webpage, 'thumbnail', default=None)
114 'thumbnail': thumbnail,