]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/cnbc.py
[extractor/youtube] Support `/live/` URL
[yt-dlp.git] / yt_dlp / extractor / cnbc.py
1 from .common import InfoExtractor
2 from ..utils import smuggle_url
3
4
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
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
35
36 class CNBCVideoIE(InfoExtractor):
37 _VALID_URL = r'https?://(?:www\.)?cnbc\.com(?P<path>/video/(?:[^/]+/)+(?P<id>[^./?#&]+)\.html)'
38 _TEST = {
39 'url': 'https://www.cnbc.com/video/2018/07/19/trump-i-dont-necessarily-agree-with-raising-rates.html',
40 'info_dict': {
41 'id': '7000031301',
42 'ext': 'mp4',
43 'title': "Trump: I don't necessarily agree with raising rates",
44 'description': 'md5:878d8f0b4ebb5bb1dda3514b91b49de3',
45 'timestamp': 1531958400,
46 'upload_date': '20180719',
47 'uploader': 'NBCU-CNBC',
48 },
49 'params': {
50 'skip_download': True,
51 },
52 }
53
54 def _real_extract(self, url):
55 path, display_id = self._match_valid_url(url).groups()
56 video_id = self._download_json(
57 'https://webql-redesign.cnbcfm.com/graphql', display_id, query={
58 'query': '''{
59 page(path: "%s") {
60 vcpsId
61 }
62 }''' % path,
63 })['data']['page']['vcpsId']
64 return self.url_result(
65 'http://video.cnbc.com/gallery/?video=%d' % video_id,
66 CNBCIE.ie_key())