2 from __future__ import unicode_literals
7 from .common import InfoExtractor
14 class CNETIE(InfoExtractor):
15 _VALID_URL = r'https?://(?:www\.)?cnet\.com/videos/(?P<id>[^/]+)/'
17 'url': 'http://www.cnet.com/videos/hands-on-with-microsofts-windows-8-1-update/',
18 'md5': '041233212a0d06b179c87cbcca1577b8',
20 'id': '56f4ea68-bd21-4852-b08c-4de5b8354c60',
22 'title': 'Hands-on with Microsoft Windows 8.1 Update',
23 'description': 'The new update to the Windows 8 OS brings improved performance for mouse and keyboard users.',
24 'thumbnail': 're:^http://.*/flmswindows8.jpg$',
25 'uploader_id': 'sarah.mitroff@cbsinteractive.com',
26 'uploader': 'Sarah Mitroff',
30 def _real_extract(self, url):
31 mobj = re.match(self._VALID_URL, url)
32 display_id = mobj.group('id')
34 webpage = self._download_webpage(url, display_id)
35 data_json = self._html_search_regex(
36 r"<div class=\"cnetVideoPlayer\"\s+.*?data-cnet-video-options='([^']+)'",
38 data = json.loads(data_json)
41 vdata = data['videos'][0]
43 raise ExtractorError('Cannot find video data')
45 video_id = vdata['id']
46 title = vdata.get('headline')
48 title = vdata.get('title')
50 raise ExtractorError('Cannot find title!')
51 description = vdata.get('dek')
52 thumbnail = vdata.get('image', {}).get('path')
53 author = vdata.get('author')
55 uploader = '%s %s' % (author['firstName'], author['lastName'])
56 uploader_id = author.get('email')
62 'format_id': '%s-%s-%s' % (
63 f['type'], f['format'],
64 int_or_none(f.get('bitrate'), 1000, default='')),
66 'tbr': int_or_none(f.get('bitrate'), 1000),
67 } for f in vdata['files']['data']]
68 self._sort_formats(formats)
72 'display_id': display_id,
75 'description': description,
77 'uploader_id': uploader_id,
78 'thumbnail': thumbnail,