2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
5 from .cbs
import CBSBaseIE
11 class CBSNewsIE(CBSBaseIE
):
13 _VALID_URL
= r
'https?://(?:www\.)?cbsnews\.com/(?:news|videos)/(?P<id>[\da-z_-]+)'
17 'url': 'http://www.cbsnews.com/news/tesla-and-spacex-elon-musks-industrial-empire/',
19 'id': 'tesla-and-spacex-elon-musks-industrial-empire',
21 'title': 'Tesla and SpaceX: Elon Musk\'s industrial empire',
22 'thumbnail': 'http://beta.img.cbsnews.com/i/2014/03/30/60147937-2f53-4565-ad64-1bdd6eb64679/60-0330-pelley-640x360.jpg',
27 'skip_download': True,
29 'skip': 'Subscribers only',
32 'url': 'http://www.cbsnews.com/videos/fort-hood-shooting-army-downplays-mental-illness-as-cause-of-attack/',
34 'id': 'SNJBOYzXiWBOvaLsdzwH8fmtP1SCd91Y',
36 'title': 'Fort Hood shooting: Army downplays mental illness as cause of attack',
37 'description': 'md5:4a6983e480542d8b333a947bfc64ddc7',
38 'upload_date': '19700101',
39 'uploader': 'CBSI-NEW',
40 'thumbnail': 're:^https?://.*\.jpg$',
50 'skip_download': True,
55 def _real_extract(self
, url
):
56 video_id
= self
._match
_id
(url
)
58 webpage
= self
._download
_webpage
(url
, video_id
)
60 video_info
= self
._parse
_json
(self
._html
_search
_regex
(
61 r
'(?:<ul class="media-list items" id="media-related-items"><li data-video-info|<div id="cbsNewsVideoPlayer" data-video-player-options)=\'({.+?
})\'',
62 webpage, 'video JSON info
'), video_id)
64 item = video_info['item
'] if 'item
' in video_info else video_info
65 guid = item['mpxRefId
']
66 return self._extract_video_info('byGuid
=%s' % guid, guid)
69 class CBSNewsLiveVideoIE(InfoExtractor):
70 IE_DESC = 'CBS News Live Videos
'
71 _VALID_URL = r'https?
://(?
:www\
.)?cbsnews\
.com
/live
/video
/(?P
<id>[\da
-z_
-]+)'
73 # Live videos get deleted soon. See http://www.cbsnews.com/live/ for the latest examples
75 'url
': 'http
://www
.cbsnews
.com
/live
/video
/clinton
-sanders
-prepare
-to
-face
-off
-in-nh
/',
77 'id': 'clinton
-sanders
-prepare
-to
-face
-off
-in-nh
',
79 'title
': 'Clinton
, Sanders Prepare To Face Off In NH
',
85 def _real_extract(self, url):
86 video_id = self._match_id(url)
88 webpage = self._download_webpage(url, video_id)
90 video_info = self._parse_json(self._html_search_regex(
91 r'data
-story
-obj
=\'({.+?
})\'', webpage, 'video JSON info
'), video_id)['story
']
93 hdcore_sign = 'hdcore
=3.3.1'
94 f4m_formats = self._extract_f4m_formats(video_info['url
'] + '&' + hdcore_sign, video_id)
96 for entry in f4m_formats:
97 # URLs without the extra param induce an 404 error
98 entry.update({'extra_param_to_segment_url
': hdcore_sign})
99 self._sort_formats(f4m_formats)
103 'title
': video_info['headline
'],
104 'thumbnail
': video_info.get('thumbnail_url_hd
') or video_info.get('thumbnail_url_sd
'),
105 'duration
': parse_duration(video_info.get('segmentDur
')),
106 'formats
': f4m_formats,