You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.7 KiB

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