cnbc.py 2.2 KB

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