youtube-dl

Another place where youtube-dl lives on
git clone git://git.oshgnacknak.de/youtube-dl.git
Log | Files | Refs | README | LICENSE

cnbc.py (2293B)


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