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:81715fa9c4ea3d9e7915dc8180c778ed',
24 'thumbnail': 're:^https?://.*\.jpg$',
25 'timestamp': 1411896237,
26 'upload_date': '20140928',
31 'skip_download': True,
34 'url': 'http://news.sportbox.ru/Vidy_sporta/billiard/spbvideo_NI486287_CHempionat-mira-po-dinamichnoy-piramide-4',
35 'only_matching': True,
37 'url': 'http://news.sportbox.ru/video/no_ads/spbvideo_NI536574_V_Novorossijske_proshel_detskij_turnir_Pole_slavy_bojevoj?ci=211355',
38 'only_matching': True,
41 def _real_extract(self, url):
42 mobj = re.match(self._VALID_URL, url)
43 display_id = mobj.group('display_id')
45 webpage = self._download_webpage(url, display_id)
47 player = self._search_regex(
48 r'src="/?(vdl/player/[^"]+)"', webpage, 'player')
50 title = self._html_search_regex(
51 r'<h1 itemprop="name">([^<]+)</h1>', webpage, 'title')
52 description = self._html_search_regex(
53 r'(?s)<div itemprop="description">(.+?)</div>',
54 webpage, 'description', fatal=False)
55 thumbnail = self._og_search_thumbnail(webpage)
56 timestamp = parse_iso8601(self._search_regex(
57 r'<span itemprop="uploadDate">([^<]+)</span>',
58 webpage, 'timestamp', fatal=False))
59 duration = parse_duration(self._html_search_regex(
60 r'<meta itemprop="duration" content="PT([^"]+)">',
61 webpage, 'duration', fatal=False))
64 '_type': 'url_transparent',
65 'url': compat_urlparse.urljoin(url, '/%s' % player),
66 'display_id': display_id,
68 'description': description,
69 'thumbnail': thumbnail,
70 'timestamp': timestamp,
75 class SportBoxEmbedIE(InfoExtractor):
76 _VALID_URL = r'https?://news\.sportbox\.ru/vdl/player(?:/[^/]+/|\?.*?\bn?id=)(?P<id>\d+)'
78 'url': 'http://news.sportbox.ru/vdl/player/ci/211355',
82 'title': 'В Новороссийске прошел детский турнир «Поле славы боевой»',
83 'thumbnail': 're:^https?://.*\.jpg$',
87 'skip_download': True,
90 'url': 'http://news.sportbox.ru/vdl/player?nid=370908&only_player=1&autostart=false&playeri=2&height=340&width=580',
91 'only_matching': True,
95 def _extract_urls(webpage):
97 r'<iframe[^>]+src="(https?://news\.sportbox\.ru/vdl/player[^"]+)"',
100 def _real_extract(self, url):
101 video_id = self._match_id(url)
103 webpage = self._download_webpage(url, video_id)
105 hls = self._search_regex(
106 r"sportboxPlayer\.jwplayer_common_params\.file\s*=\s*['\"]([^'\"]+)['\"]",
109 formats = self._extract_m3u8_formats(hls, video_id, 'mp4')
111 title = self._search_regex(
112 r'sportboxPlayer\.node_title\s*=\s*"([^"]+)"', webpage, 'title')
114 thumbnail = self._search_regex(
115 r'sportboxPlayer\.jwplayer_common_params\.image\s*=\s*"([^"]+)"',
116 webpage, 'thumbnail', default=None)
121 'thumbnail': thumbnail,