]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/webcaster.py
7486cb347d8523a932c2bddd56f26c9a95f78641
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
13 class WebcasterIE(InfoExtractor
):
14 _VALID_URL
= r
'https?://bl\.webcaster\.pro/(?:quote|media)/start/free_(?P<id>[^/]+)'
16 # http://video.khl.ru/quotes/393859
17 'url': 'http://bl.webcaster.pro/quote/start/free_c8cefd240aa593681c8d068cff59f407_hd/q393859/eb173f99dd5f558674dae55f4ba6806d/1480289104?sr%3D105%26fa%3D1%26type_id%3D18',
18 'md5': '0c162f67443f30916ff1c89425dcd4cd',
20 'id': 'c8cefd240aa593681c8d068cff59f407_hd',
22 'title': 'Сибирь - Нефтехимик. Лучшие моменты первого периода',
23 'thumbnail': 're:^https?://.*\.jpg$',
26 'url': 'http://bl.webcaster.pro/media/start/free_6246c7a4453ac4c42b4398f840d13100_hd/2_2991109016/e8d0d82587ef435480118f9f9c41db41/4635726126',
27 'only_matching': True,
30 def _real_extract(self
, url
):
31 video_id
= self
._match
_id
(url
)
33 video
= self
._download
_xml
(url
, video_id
)
35 title
= xpath_text(video
, './/event_name', 'event name', fatal
=True)
37 def make_id(parts
, separator
):
38 return separator
.join(filter(None, parts
))
41 for format_id
in (None, 'noise'):
42 track_tag
= make_id(('track', format_id
), '_')
43 for track
in video
.findall('.//iphone/%s' % track_tag
):
44 track_url
= track
.text
47 if determine_ext(track_url
) == 'm3u8':
48 m3u8_formats
= self
._extract
_m
3u8_formats
(
49 track_url
, video_id
, 'mp4',
50 entry_protocol
='m3u8_native',
51 m3u8_id
=make_id(('hls', format_id
), '-'), fatal
=False)
52 for f
in m3u8_formats
:
54 'source_preference': 0 if format_id
== 'noise' else 1,
55 'format_note': track
.get('title'),
57 formats
.extend(m3u8_formats
)
58 self
._sort
_formats
(formats
)
60 thumbnail
= xpath_text(video
, './/image', 'thumbnail')
65 'thumbnail': thumbnail
,
70 class WebcasterFeedIE(InfoExtractor
):
71 _VALID_URL
= r
'https?://bl\.webcaster\.pro/feed/start/free_(?P<id>[^/]+)'
73 'url': 'http://bl.webcaster.pro/feed/start/free_c8cefd240aa593681c8d068cff59f407_hd/q393859/eb173f99dd5f558674dae55f4ba6806d/1480289104',
74 'only_matching': True,
78 def _extract_url(ie
, webpage
):
80 r
'<(?:object|a[^>]+class=["\']webcaster
-player
["\'])[^>]+data(?:-config)?=(["\']).*?config
=(?P
<url
>https?
://bl\
.webcaster\
.pro
/feed
/start
/free_
.*?
)(?
:[?
&]|\
1)',
83 return mobj.group('url
')
84 for secure in (True, False):
85 video_url = ie._og_search_video_url(
86 webpage, secure=secure, default=None)
89 r'config
=(?P
<url
>https?
://bl\
.webcaster\
.pro
/feed
/start
/free_
[^?
&=]+)',
92 return mobj.group('url
')
94 def _real_extract(self, url):
95 video_id = self._match_id(url)
97 feed = self._download_xml(url, video_id)
99 video_url = xpath_text(
100 feed, ('video_hd
', 'video
'), 'video url
', fatal=True)
102 return self.url_result(video_url, WebcasterIE.ie_key())