]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/bloomberg.py
Merge tag 'upstream/2015.07.21'
[youtubedl] / youtube_dl / extractor / bloomberg.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6
7
8 class BloombergIE(InfoExtractor):
9 _VALID_URL = r'https?://www\.bloomberg\.com/news/videos/[^/]+/(?P<id>[^/?#]+)'
10
11 _TEST = {
12 'url': 'http://www.bloomberg.com/news/videos/b/aaeae121-5949-481e-a1ce-4562db6f5df2',
13 # The md5 checksum changes
14 'info_dict': {
15 'id': 'qurhIVlJSB6hzkVi229d8g',
16 'ext': 'flv',
17 'title': 'Shah\'s Presentation on Foreign-Exchange Strategies',
18 'description': 'md5:a8ba0302912d03d246979735c17d2761',
19 },
20 }
21
22 def _real_extract(self, url):
23 name = self._match_id(url)
24 webpage = self._download_webpage(url, name)
25 video_id = self._search_regex(r'"bmmrId":"(.+?)"', webpage, 'id')
26 title = re.sub(': Video$', '', self._og_search_title(webpage))
27
28 embed_info = self._download_json(
29 'http://www.bloomberg.com/api/embed?id=%s' % video_id, video_id)
30 formats = []
31 for stream in embed_info['streams']:
32 if stream["muxing_format"] == "TS":
33 formats.extend(self._extract_m3u8_formats(stream['url'], video_id))
34 else:
35 formats.extend(self._extract_f4m_formats(stream['url'], video_id))
36 self._sort_formats(formats)
37
38 return {
39 'id': video_id,
40 'title': title,
41 'formats': formats,
42 'description': self._og_search_description(webpage),
43 'thumbnail': self._og_search_thumbnail(webpage),
44 }