]>
Commit | Line | Data |
---|---|---|
c02ec7d4 | 1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
8bdd16b4 | 4 | import re |
ffa7b2bf | 5 | |
c02ec7d4 | 6 | from .common import InfoExtractor |
94db1f7f | 7 | from ..utils import smuggle_url |
c02ec7d4 | 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', | |
c02ec7d4 | 14 | 'info_dict': { |
15 | 'id': '3000503714', | |
16 | 'ext': 'mp4', | |
ce548296 | 17 | 'title': 'Fighting zombies is big business', |
18 | 'description': 'md5:0c100d8e1a7947bd2feec9a5550e519e', | |
79ba9140 | 19 | 'timestamp': 1459332000, |
20 | 'upload_date': '20160330', | |
21 | 'uploader': 'NBCU-CNBC', | |
ce548296 | 22 | }, |
23 | 'params': { | |
24 | # m3u8 download | |
25 | 'skip_download': True, | |
26 | }, | |
c02ec7d4 | 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 | } | |
ffa7b2bf | 39 | |
40 | ||
94db1f7f | 41 | class CNBCVideoIE(InfoExtractor): |
8bdd16b4 | 42 | _VALID_URL = r'https?://(?:www\.)?cnbc\.com(?P<path>/video/(?:[^/]+/)+(?P<id>[^./?#&]+)\.html)' |
ffa7b2bf | 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', | |
94db1f7f | 48 | 'title': "Trump: I don't necessarily agree with raising rates", |
ffa7b2bf | 49 | 'description': 'md5:878d8f0b4ebb5bb1dda3514b91b49de3', |
50 | 'timestamp': 1531958400, | |
51 | 'upload_date': '20180719', | |
52 | 'uploader': 'NBCU-CNBC', | |
53 | }, | |
54 | 'params': { | |
ffa7b2bf | 55 | 'skip_download': True, |
56 | }, | |
57 | } | |
58 | ||
ffa7b2bf | 59 | def _real_extract(self, url): |
8bdd16b4 | 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'] | |
94db1f7f | 69 | return self.url_result( |
8bdd16b4 | 70 | 'http://video.cnbc.com/gallery/?video=%d' % video_id, |
94db1f7f | 71 | CNBCIE.ie_key()) |