]>
Commit | Line | Data |
---|---|---|
9271bc83 PH |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
fe7ef95e | 4 | |
96820c1c | 5 | from .cbs import CBSIE |
c6ed6fad | 6 | from ..utils import int_or_none |
9271bc83 PH |
7 | |
8 | ||
96820c1c | 9 | class CBSInteractiveIE(CBSIE): |
03327bc9 | 10 | _VALID_URL = r'https?://(?:www\.)?(?P<site>cnet|zdnet)\.com/(?:videos|video(?:/share)?)/(?P<id>[^/?]+)' |
788be331 | 11 | _TESTS = [{ |
9271bc83 | 12 | 'url': 'http://www.cnet.com/videos/hands-on-with-microsofts-windows-8-1-update/', |
9271bc83 | 13 | 'info_dict': { |
96820c1c TF |
14 | 'id': 'R49SYt__yAfmlXR85z4f7gNmCBDcN_00', |
15 | 'display_id': 'hands-on-with-microsofts-windows-8-1-update', | |
e095109d | 16 | 'ext': 'mp4', |
9271bc83 PH |
17 | 'title': 'Hands-on with Microsoft Windows 8.1 Update', |
18 | 'description': 'The new update to the Windows 8 OS brings improved performance for mouse and keyboard users.', | |
412c617d | 19 | 'uploader_id': '6085384d-619e-11e3-b231-14feb5ca9861', |
9271bc83 | 20 | 'uploader': 'Sarah Mitroff', |
c6ed6fad | 21 | 'duration': 70, |
5f705baf | 22 | 'timestamp': 1396479627, |
23 | 'upload_date': '20140402', | |
412c617d | 24 | }, |
e095109d | 25 | 'params': { |
96820c1c TF |
26 | # m3u8 download |
27 | 'skip_download': True, | |
e095109d | 28 | }, |
788be331 YCH |
29 | }, { |
30 | 'url': 'http://www.cnet.com/videos/whiny-pothole-tweets-at-local-government-when-hit-by-cars-tomorrow-daily-187/', | |
96820c1c | 31 | 'md5': 'f11d27b2fa18597fbf92444d2a9ed386', |
788be331 | 32 | 'info_dict': { |
96820c1c TF |
33 | 'id': 'kjOJd_OoVJqbg_ZD8MZCOk8Wekb9QccK', |
34 | 'display_id': 'whiny-pothole-tweets-at-local-government-when-hit-by-cars-tomorrow-daily-187', | |
e095109d | 35 | 'ext': 'mp4', |
c6ed6fad | 36 | 'title': 'Whiny potholes tweet at local government when hit by cars (Tomorrow Daily 187)', |
96820c1c | 37 | 'description': 'md5:d2b9a95a5ffe978ae6fbd4cf944d618f', |
788be331 YCH |
38 | 'uploader_id': 'b163284d-6b73-44fc-b3e6-3da66c392d40', |
39 | 'uploader': 'Ashley Esqueda', | |
c6ed6fad | 40 | 'duration': 1482, |
5f705baf | 41 | 'timestamp': 1433289889, |
42 | 'upload_date': '20150603', | |
788be331 | 43 | }, |
fe7ef95e | 44 | }, { |
45 | 'url': 'http://www.zdnet.com/video/share/video-keeping-android-smartphones-and-tablets-secure/', | |
46 | 'info_dict': { | |
96820c1c TF |
47 | 'id': 'k0r4T_ehht4xW_hAOqiVQPuBDPZ8SRjt', |
48 | 'display_id': 'video-keeping-android-smartphones-and-tablets-secure', | |
fe7ef95e | 49 | 'ext': 'mp4', |
50 | 'title': 'Video: Keeping Android smartphones and tablets secure', | |
51 | 'description': 'Here\'s the best way to keep Android devices secure, and what you do when they\'ve come to the end of their lives.', | |
52 | 'uploader_id': 'f2d97ea2-8175-11e2-9d12-0018fe8a00b0', | |
53 | 'uploader': 'Adrian Kingsley-Hughes', | |
96820c1c | 54 | 'duration': 731, |
e095109d TF |
55 | 'timestamp': 1449129925, |
56 | 'upload_date': '20151203', | |
fe7ef95e | 57 | }, |
58 | 'params': { | |
59 | # m3u8 download | |
60 | 'skip_download': True, | |
96820c1c | 61 | }, |
03327bc9 S |
62 | }, { |
63 | 'url': 'http://www.zdnet.com/video/huawei-matebook-x-video/', | |
64 | 'only_matching': True, | |
788be331 | 65 | }] |
96820c1c | 66 | |
fe7ef95e | 67 | MPX_ACCOUNTS = { |
96820c1c | 68 | 'cnet': 2198311517, |
fe7ef95e | 69 | 'zdnet': 2387448114, |
70 | } | |
9271bc83 PH |
71 | |
72 | def _real_extract(self, url): | |
5ad28e7f | 73 | site, display_id = self._match_valid_url(url).groups() |
9271bc83 | 74 | webpage = self._download_webpage(url, display_id) |
412c617d | 75 | |
9271bc83 | 76 | data_json = self._html_search_regex( |
d2a422f5 | 77 | r"data(?:-(?:cnet|zdnet))?-video(?:-(?:uvp(?:js)?|player))?-options='([^']+)'", |
9271bc83 | 78 | webpage, 'data json') |
c6ed6fad | 79 | data = self._parse_json(data_json, display_id) |
d2a422f5 | 80 | vdata = data.get('video') or (data.get('videos') or data.get('playlist'))[0] |
412c617d | 81 | |
96820c1c TF |
82 | video_id = vdata['mpxRefId'] |
83 | ||
b306c439 | 84 | title = vdata['title'] |
9271bc83 PH |
85 | author = vdata.get('author') |
86 | if author: | |
87 | uploader = '%s %s' % (author['firstName'], author['lastName']) | |
412c617d | 88 | uploader_id = author.get('id') |
9271bc83 PH |
89 | else: |
90 | uploader = None | |
91 | uploader_id = None | |
92 | ||
96820c1c | 93 | info = self._extract_video_info(video_id, site, self.MPX_ACCOUNTS[site]) |
5f705baf | 94 | info.update({ |
9271bc83 PH |
95 | 'id': video_id, |
96 | 'display_id': display_id, | |
97 | 'title': title, | |
5f705baf | 98 | 'duration': int_or_none(vdata.get('duration')), |
9271bc83 PH |
99 | 'uploader': uploader, |
100 | 'uploader_id': uploader_id, | |
5f705baf | 101 | }) |
102 | return info |