]>
Commit | Line | Data |
---|---|---|
7e70ac36 JMF |
1 | from __future__ import unicode_literals |
2 | ||
4b6462fc JMF |
3 | import re |
4 | ||
5 | from .common import InfoExtractor | |
6 | ||
7 | ||
8 | class BloombergIE(InfoExtractor): | |
7ad4258a | 9 | _VALID_URL = r'https?://(?:www\.)?bloomberg\.com/(?:[^/]+/)*(?P<id>[^/?#]+)' |
4b6462fc | 10 | |
342609a1 | 11 | _TESTS = [{ |
ff2be6e1 | 12 | 'url': 'http://www.bloomberg.com/news/videos/b/aaeae121-5949-481e-a1ce-4562db6f5df2', |
31bb8d3f | 13 | # The md5 checksum changes |
7e70ac36 JMF |
14 | 'info_dict': { |
15 | 'id': 'qurhIVlJSB6hzkVi229d8g', | |
16 | 'ext': 'flv', | |
17 | 'title': 'Shah\'s Presentation on Foreign-Exchange Strategies', | |
ff2be6e1 | 18 | 'description': 'md5:a8ba0302912d03d246979735c17d2761', |
4b6462fc | 19 | }, |
342609a1 S |
20 | }, { |
21 | 'url': 'http://www.bloomberg.com/news/articles/2015-11-12/five-strange-things-that-have-been-happening-in-financial-markets', | |
22 | 'only_matching': True, | |
7ad4258a S |
23 | }, { |
24 | 'url': 'http://www.bloomberg.com/politics/videos/2015-11-25/karl-rove-on-jeb-bush-s-struggles-stopping-trump', | |
25 | 'only_matching': True, | |
342609a1 | 26 | }] |
4b6462fc JMF |
27 | |
28 | def _real_extract(self, url): | |
ec5913b5 | 29 | name = self._match_id(url) |
4b6462fc | 30 | webpage = self._download_webpage(url, name) |
4191fdf1 S |
31 | video_id = self._search_regex( |
32 | r'["\']bmmrId["\']\s*:\s*(["\'])(?P<url>.+?)\1', | |
33 | webpage, 'id', group='url') | |
7e70ac36 JMF |
34 | title = re.sub(': Video$', '', self._og_search_title(webpage)) |
35 | ||
ff2be6e1 JMF |
36 | embed_info = self._download_json( |
37 | 'http://www.bloomberg.com/api/embed?id=%s' % video_id, video_id) | |
38 | formats = [] | |
39 | for stream in embed_info['streams']: | |
b7faebba S |
40 | stream_url = stream.get('url') |
41 | if not stream_url: | |
42 | continue | |
9a4f12be | 43 | if stream['muxing_format'] == 'TS': |
7e5edcfd S |
44 | formats.extend(self._extract_m3u8_formats( |
45 | stream_url, video_id, 'mp4', m3u8_id='hls', fatal=False)) | |
ff2be6e1 | 46 | else: |
7e5edcfd S |
47 | formats.extend(self._extract_f4m_formats( |
48 | stream_url, video_id, f4m_id='hds', fatal=False)) | |
ff2be6e1 JMF |
49 | self._sort_formats(formats) |
50 | ||
7e70ac36 | 51 | return { |
ff2be6e1 | 52 | 'id': video_id, |
7e70ac36 | 53 | 'title': title, |
ff2be6e1 | 54 | 'formats': formats, |
7e70ac36 JMF |
55 | 'description': self._og_search_description(webpage), |
56 | 'thumbnail': self._og_search_thumbnail(webpage), | |
57 | } |