2 from __future__ import unicode_literals
6 from .theplatform import ThePlatformIE
7 from ..compat import compat_urllib_parse
8 from ..utils import int_or_none
11 class CBSInteractiveIE(ThePlatformIE):
12 _VALID_URL = r'https?://(?:www\.)?(?P<site>cnet|zdnet)\.com/(?:videos|video/share)/(?P<id>[^/?]+)'
14 'url': 'http://www.cnet.com/videos/hands-on-with-microsofts-windows-8-1-update/',
15 'md5': '041233212a0d06b179c87cbcca1577b8',
17 'id': '56f4ea68-bd21-4852-b08c-4de5b8354c60',
19 'title': 'Hands-on with Microsoft Windows 8.1 Update',
20 'description': 'The new update to the Windows 8 OS brings improved performance for mouse and keyboard users.',
21 'uploader_id': '6085384d-619e-11e3-b231-14feb5ca9861',
22 'uploader': 'Sarah Mitroff',
24 'timestamp': 1396479627,
25 'upload_date': '20140402',
31 'url': 'http://www.cnet.com/videos/whiny-pothole-tweets-at-local-government-when-hit-by-cars-tomorrow-daily-187/',
32 'md5': 'f2b16d73e08d69591dd9e25564695c0c',
34 'id': '56527b93-d25d-44e3-b738-f989ce2e49ba',
36 'title': 'Whiny potholes tweet at local government when hit by cars (Tomorrow Daily 187)',
37 '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',
38 'uploader_id': 'b163284d-6b73-44fc-b3e6-3da66c392d40',
39 'uploader': 'Ashley Esqueda',
41 'timestamp': 1433289889,
42 'upload_date': '20150603',
48 'url': 'http://www.zdnet.com/video/share/video-keeping-android-smartphones-and-tablets-secure/',
50 'id': 'bc1af9f0-a2b5-4e54-880d-0d95525781c0',
52 'title': 'Video: Keeping Android smartphones and tablets secure',
53 '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.',
54 'uploader_id': 'f2d97ea2-8175-11e2-9d12-0018fe8a00b0',
55 'uploader': 'Adrian Kingsley-Hughes',
56 'timestamp': 1449129925,
57 'upload_date': '20151203',
61 'skip_download': True,
64 TP_RELEASE_URL_TEMPLATE = 'http://link.theplatform.com/s/kYEXFC/%s?mbr=true'
70 def _real_extract(self, url):
71 site, display_id = re.match(self._VALID_URL, url).groups()
72 webpage = self._download_webpage(url, display_id)
74 data_json = self._html_search_regex(
75 r"data-(?:cnet|zdnet)-video(?:-uvp(?:js)?)?-options='([^']+)'",
77 data = self._parse_json(data_json, display_id)
78 vdata = data.get('video') or data['videos'][0]
80 video_id = vdata['id']
81 title = vdata['title']
82 author = vdata.get('author')
84 uploader = '%s %s' % (author['firstName'], author['lastName'])
85 uploader_id = author.get('id')
90 media_guid_path = 'media/guid/%d/%s' % (self.MPX_ACCOUNTS[site], vdata['mpxRefId'])
91 formats, subtitles = [], {}
92 for (fkey, vid) in vdata.get('files', {}).items():
93 if fkey == 'hls_phone' and 'hls_tablet' in vdata['files']:
95 release_url = self.TP_RELEASE_URL_TEMPLATE % vid
97 release_url += '&manifest=f4m'
98 tp_formats, tp_subtitles = self._extract_theplatform_smil(release_url, video_id, 'Downloading %s SMIL data' % fkey)
99 formats.extend(tp_formats)
100 subtitles = self._merge_subtitles(subtitles, tp_subtitles)
103 parsed_url = compat_urllib_parse.urlparse(url)
104 m3u8_url = ('%s://%s%s'
105 % (parsed_url.scheme, parsed_url.netloc, vdata['m3u8']))
106 m3u8_formats = self._extract_m3u8_formats(m3u8_url, video_id)
107 for format in m3u8_formats:
108 format['url'] = format['url'].replace('https://', 'http://')
109 formats.extend(m3u8_formats)
118 self._sort_formats(formats)
120 info = self._extract_theplatform_metadata('kYEXFC/%s' % media_guid_path, video_id)
123 'display_id': display_id,
125 'duration': int_or_none(vdata.get('duration')),
126 'uploader': uploader,
127 'uploader_id': uploader_id,
128 'subtitles': subtitles,