logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

cnbc.py (2293B)


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