]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/cnet.py
a94f42571746f21cc70ba2527e661952caca1c6f
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['headline
']
47 description = vdata.get('dek
')
48 thumbnail = vdata.get('image
', {}).get('path
')
49 author = vdata.get('author
')
51 uploader = '%s %s' % (author['firstName
'], author['lastName
'])
52 uploader_id = author.get('email
')
58 'format_id
': '%s-%s-%s' % (
59 f['type'], f['format
'],
60 int_or_none(f.get('bitrate
'), 1000, default='')),
62 'tbr
': int_or_none(f.get('bitrate
'), 1000),
63 } for f in vdata['files
']['data
']]
64 self._sort_formats(formats)
68 'display_id
': display_id,
71 'description
': description,
73 'uploader_id
': uploader_id,
74 'thumbnail
': thumbnail,