]>
Commit | Line | Data |
---|---|---|
9271bc83 PH |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
fe7ef95e | 4 | import re |
5 | ||
b306c439 | 6 | from .theplatform import ThePlatformIE |
c6ed6fad | 7 | from ..utils import int_or_none |
9271bc83 PH |
8 | |
9 | ||
fe7ef95e | 10 | class CBSInteractiveIE(ThePlatformIE): |
11 | _VALID_URL = r'https?://(?:www\.)?(?P<site>cnet|zdnet)\.com/(?:videos|video/share)/(?P<id>[^/?]+)' | |
788be331 | 12 | _TESTS = [{ |
9271bc83 | 13 | 'url': 'http://www.cnet.com/videos/hands-on-with-microsofts-windows-8-1-update/', |
9271bc83 PH |
14 | 'info_dict': { |
15 | 'id': '56f4ea68-bd21-4852-b08c-4de5b8354c60', | |
c6ed6fad | 16 | 'ext': 'flv', |
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 | }, |
788be331 YCH |
25 | }, { |
26 | 'url': 'http://www.cnet.com/videos/whiny-pothole-tweets-at-local-government-when-hit-by-cars-tomorrow-daily-187/', | |
27 | 'info_dict': { | |
28 | 'id': '56527b93-d25d-44e3-b738-f989ce2e49ba', | |
c6ed6fad | 29 | 'ext': 'flv', |
30 | 'title': 'Whiny potholes tweet at local government when hit by cars (Tomorrow Daily 187)', | |
788be331 YCH |
31 | 'description': 'Khail and Ashley wonder what other civic woes can be solved by self-tweeting objects, investigate a new kind of VR camera and watch an origami robot self-assemble, walk, climb, dig and dissolve. #TDPothole', |
32 | 'uploader_id': 'b163284d-6b73-44fc-b3e6-3da66c392d40', | |
33 | 'uploader': 'Ashley Esqueda', | |
c6ed6fad | 34 | 'duration': 1482, |
5f705baf | 35 | 'timestamp': 1433289889, |
36 | 'upload_date': '20150603', | |
788be331 | 37 | }, |
fe7ef95e | 38 | }, { |
39 | 'url': 'http://www.zdnet.com/video/share/video-keeping-android-smartphones-and-tablets-secure/', | |
40 | 'info_dict': { | |
41 | 'id': 'bc1af9f0-a2b5-4e54-880d-0d95525781c0', | |
42 | 'ext': 'mp4', | |
43 | 'title': 'Video: Keeping Android smartphones and tablets secure', | |
44 | '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.', | |
45 | 'uploader_id': 'f2d97ea2-8175-11e2-9d12-0018fe8a00b0', | |
46 | 'uploader': 'Adrian Kingsley-Hughes', | |
47 | 'timestamp': 1448961720, | |
48 | 'upload_date': '20151201', | |
49 | }, | |
50 | 'params': { | |
51 | # m3u8 download | |
52 | 'skip_download': True, | |
53 | } | |
788be331 | 54 | }] |
5f705baf | 55 | TP_RELEASE_URL_TEMPLATE = 'http://link.theplatform.com/s/kYEXFC/%s?mbr=true' |
fe7ef95e | 56 | MPX_ACCOUNTS = { |
57 | 'cnet': 2288573011, | |
58 | 'zdnet': 2387448114, | |
59 | } | |
9271bc83 PH |
60 | |
61 | def _real_extract(self, url): | |
fe7ef95e | 62 | site, display_id = re.match(self._VALID_URL, url).groups() |
9271bc83 | 63 | webpage = self._download_webpage(url, display_id) |
412c617d | 64 | |
9271bc83 | 65 | data_json = self._html_search_regex( |
fe7ef95e | 66 | r"data-(?:cnet|zdnet)-video(?:-uvp)?-options='([^']+)'", |
9271bc83 | 67 | webpage, 'data json') |
c6ed6fad | 68 | data = self._parse_json(data_json, display_id) |
69 | vdata = data.get('video') or data['videos'][0] | |
412c617d | 70 | |
9271bc83 | 71 | video_id = vdata['id'] |
b306c439 | 72 | title = vdata['title'] |
9271bc83 PH |
73 | author = vdata.get('author') |
74 | if author: | |
75 | uploader = '%s %s' % (author['firstName'], author['lastName']) | |
412c617d | 76 | uploader_id = author.get('id') |
9271bc83 PH |
77 | else: |
78 | uploader = None | |
79 | uploader_id = None | |
80 | ||
fe7ef95e | 81 | media_guid_path = 'media/guid/%d/%s' % (self.MPX_ACCOUNTS[site], vdata['mpxRefId']) |
82 | formats, subtitles = [], {} | |
a641b245 | 83 | for (fkey, vid) in vdata['files'].items(): |
84 | if fkey == 'hls_phone' and 'hls_tablet' in vdata['files']: | |
85 | continue | |
5f705baf | 86 | release_url = self.TP_RELEASE_URL_TEMPLATE % vid |
c6ed6fad | 87 | if fkey == 'hds': |
88 | release_url += '&manifest=f4m' | |
89 | tp_formats, tp_subtitles = self._extract_theplatform_smil(release_url, video_id, 'Downloading %s SMIL data' % fkey) | |
90 | formats.extend(tp_formats) | |
91 | subtitles = self._merge_subtitles(subtitles, tp_subtitles) | |
b306c439 | 92 | self._sort_formats(formats) |
93 | ||
bf830248 | 94 | info = self._extract_theplatform_metadata('kYEXFC/%s' % media_guid_path, video_id) |
5f705baf | 95 | info.update({ |
9271bc83 PH |
96 | 'id': video_id, |
97 | 'display_id': display_id, | |
98 | 'title': title, | |
5f705baf | 99 | 'duration': int_or_none(vdata.get('duration')), |
9271bc83 PH |
100 | 'uploader': uploader, |
101 | 'uploader_id': uploader_id, | |
b306c439 | 102 | 'subtitles': subtitles, |
103 | 'formats': formats, | |
5f705baf | 104 | }) |
105 | return info |