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.

66 lines
2.1 KiB

9 years ago
9 years ago
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import smuggle_url
  5. class CNBCIE(InfoExtractor):
  6. _VALID_URL = r'https?://video\.cnbc\.com/gallery/\?video=(?P<id>[0-9]+)'
  7. _TEST = {
  8. 'url': 'http://video.cnbc.com/gallery/?video=3000503714',
  9. 'info_dict': {
  10. 'id': '3000503714',
  11. 'ext': 'mp4',
  12. 'title': 'Fighting zombies is big business',
  13. 'description': 'md5:0c100d8e1a7947bd2feec9a5550e519e',
  14. 'timestamp': 1459332000,
  15. 'upload_date': '20160330',
  16. 'uploader': 'NBCU-CNBC',
  17. },
  18. 'params': {
  19. # m3u8 download
  20. 'skip_download': True,
  21. },
  22. }
  23. def _real_extract(self, url):
  24. video_id = self._match_id(url)
  25. return {
  26. '_type': 'url_transparent',
  27. 'ie_key': 'ThePlatform',
  28. 'url': smuggle_url(
  29. 'http://link.theplatform.com/s/gZWlPC/media/guid/2408950221/%s?mbr=true&manifest=m3u' % video_id,
  30. {'force_smil_url': True}),
  31. 'id': video_id,
  32. }
  33. class CNBCVideoIE(InfoExtractor):
  34. _VALID_URL = r'https?://(?:www\.)?cnbc\.com/video/(?:[^/]+/)+(?P<id>[^./?#&]+)'
  35. _TEST = {
  36. 'url': 'https://www.cnbc.com/video/2018/07/19/trump-i-dont-necessarily-agree-with-raising-rates.html',
  37. 'info_dict': {
  38. 'id': '7000031301',
  39. 'ext': 'mp4',
  40. 'title': "Trump: I don't necessarily agree with raising rates",
  41. 'description': 'md5:878d8f0b4ebb5bb1dda3514b91b49de3',
  42. 'timestamp': 1531958400,
  43. 'upload_date': '20180719',
  44. 'uploader': 'NBCU-CNBC',
  45. },
  46. 'params': {
  47. 'skip_download': True,
  48. },
  49. }
  50. def _real_extract(self, url):
  51. display_id = self._match_id(url)
  52. webpage = self._download_webpage(url, display_id)
  53. video_id = self._search_regex(
  54. r'content_id["\']\s*:\s*["\'](\d+)', webpage, display_id,
  55. 'video id')
  56. return self.url_result(
  57. 'http://video.cnbc.com/gallery/?video=%s' % video_id,
  58. CNBCIE.ie_key())