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.

44 lines
1.5 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/videos/[^/]+/(?P<id>[^/?#]+)'
  6. _TEST = {
  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. def _real_extract(self, url):
  17. name = self._match_id(url)
  18. webpage = self._download_webpage(url, name)
  19. video_id = self._search_regex(r'"bmmrId":"(.+?)"', webpage, 'id')
  20. title = re.sub(': Video$', '', self._og_search_title(webpage))
  21. embed_info = self._download_json(
  22. 'http://www.bloomberg.com/api/embed?id=%s' % video_id, video_id)
  23. formats = []
  24. for stream in embed_info['streams']:
  25. if stream["muxing_format"] == "TS":
  26. formats.extend(self._extract_m3u8_formats(stream['url'], video_id))
  27. else:
  28. formats.extend(self._extract_f4m_formats(stream['url'], video_id))
  29. self._sort_formats(formats)
  30. return {
  31. 'id': video_id,
  32. 'title': title,
  33. 'formats': formats,
  34. 'description': self._og_search_description(webpage),
  35. 'thumbnail': self._og_search_thumbnail(webpage),
  36. }