]>
Commit | Line | Data |
---|---|---|
9271bc83 PH |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
4 | import json | |
9271bc83 PH |
5 | |
6 | from .common import InfoExtractor | |
7 | from ..utils import ( | |
0e518e2f | 8 | ExtractorError, |
9271bc83 PH |
9 | ) |
10 | ||
11 | ||
12 | class CNETIE(InfoExtractor): | |
13 | _VALID_URL = r'https?://(?:www\.)?cnet\.com/videos/(?P<id>[^/]+)/' | |
14 | _TEST = { | |
15 | 'url': 'http://www.cnet.com/videos/hands-on-with-microsofts-windows-8-1-update/', | |
9271bc83 PH |
16 | 'info_dict': { |
17 | 'id': '56f4ea68-bd21-4852-b08c-4de5b8354c60', | |
412c617d | 18 | 'ext': 'flv', |
9271bc83 PH |
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 | 'thumbnail': 're:^http://.*/flmswindows8.jpg$', | |
412c617d | 22 | 'uploader_id': '6085384d-619e-11e3-b231-14feb5ca9861', |
9271bc83 | 23 | 'uploader': 'Sarah Mitroff', |
412c617d PH |
24 | }, |
25 | 'params': { | |
26 | 'skip_download': 'requires rtmpdump', | |
9271bc83 PH |
27 | } |
28 | } | |
29 | ||
30 | def _real_extract(self, url): | |
412c617d | 31 | display_id = self._match_id(url) |
9271bc83 | 32 | webpage = self._download_webpage(url, display_id) |
412c617d | 33 | |
9271bc83 | 34 | data_json = self._html_search_regex( |
e51880fd | 35 | r"<div class=\"cnetVideoPlayer\"\s+.*?data-cnet-video-options='([^']+)'", |
9271bc83 PH |
36 | webpage, 'data json') |
37 | data = json.loads(data_json) | |
38 | vdata = data['video'] | |
0e518e2f PH |
39 | if not vdata: |
40 | vdata = data['videos'][0] | |
41 | if not vdata: | |
42 | raise ExtractorError('Cannot find video data') | |
9271bc83 | 43 | |
412c617d PH |
44 | mpx_account = data['config']['players']['default']['mpx_account'] |
45 | vid = vdata['files']['rtmp'] | |
46 | tp_link = 'http://link.theplatform.com/s/%s/%s' % (mpx_account, vid) | |
47 | ||
9271bc83 | 48 | video_id = vdata['id'] |
6f5342a2 PH |
49 | title = vdata.get('headline') |
50 | if title is None: | |
51 | title = vdata.get('title') | |
52 | if title is None: | |
53 | raise ExtractorError('Cannot find title!') | |
9271bc83 PH |
54 | thumbnail = vdata.get('image', {}).get('path') |
55 | author = vdata.get('author') | |
56 | if author: | |
57 | uploader = '%s %s' % (author['firstName'], author['lastName']) | |
412c617d | 58 | uploader_id = author.get('id') |
9271bc83 PH |
59 | else: |
60 | uploader = None | |
61 | uploader_id = None | |
62 | ||
9271bc83 | 63 | return { |
412c617d PH |
64 | '_type': 'url_transparent', |
65 | 'url': tp_link, | |
9271bc83 PH |
66 | 'id': video_id, |
67 | 'display_id': display_id, | |
68 | 'title': title, | |
9271bc83 PH |
69 | 'uploader': uploader, |
70 | 'uploader_id': uploader_id, | |
71 | 'thumbnail': thumbnail, | |
72 | } |