2 from __future__ import unicode_literals
4 from .common import InfoExtractor
11 class CBSNewsIE(CBSIE):
14 _VALID_URL = r'https?://(?:www\.)?cbsnews\.com/(?:news|videos)/(?P<id>[\da-z_-]+)'
18 'url': 'http://www.cbsnews.com/news/tesla-and-spacex-elon-musks-industrial-empire/',
20 'id': 'tesla-and-spacex-elon-musks-industrial-empire',
22 'title': 'Tesla and SpaceX: Elon Musk\'s industrial empire',
23 'thumbnail': 'http://beta.img.cbsnews.com/i/2014/03/30/60147937-2f53-4565-ad64-1bdd6eb64679/60-0330-pelley-640x360.jpg',
28 'skip_download': True,
30 'skip': 'Subscribers only',
33 'url': 'http://www.cbsnews.com/videos/fort-hood-shooting-army-downplays-mental-illness-as-cause-of-attack/',
35 'id': 'SNJBOYzXiWBOvaLsdzwH8fmtP1SCd91Y',
37 'title': 'Fort Hood shooting: Army downplays mental illness as cause of attack',
38 'description': 'md5:4a6983e480542d8b333a947bfc64ddc7',
39 'upload_date': '20140404',
40 'timestamp': 1396650660,
41 'uploader': 'CBSI-NEW',
42 'thumbnail': r're:^https?://.*\.jpg$',
52 'skip_download': True,
56 'url': 'http://www.cbsnews.com/news/maria-ridulph-murder-will-the-nations-oldest-cold-case-to-go-to-trial-ever-get-solved/',
58 'id': 'QpM5BJjBVEAUFi7ydR9LusS69DPLqPJ1',
60 'title': 'Cold as Ice',
61 'description': 'Can a childhood memory of a friend\'s murder solve a 1957 cold case? "48 Hours" correspondent Erin Moriarty has the latest.',
62 'upload_date': '20170604',
63 'timestamp': 1496538000,
64 'uploader': 'CBSI-NEW',
67 'skip_download': True,
72 def _real_extract(self, url):
73 video_id = self._match_id(url)
75 webpage = self._download_webpage(url, video_id)
77 video_info = self._parse_json(self._html_search_regex(
78 r'(?:<ul class="media-list items" id="media-related-items"[^>]*><li data-video-info|<div id="cbsNewsVideoPlayer" data-video-player-options)=\'({.+?})\'',
79 webpage, 'video JSON info', default='{}'), video_id, fatal=False)
82 item = video_info['item'] if 'item' in video_info else video_info
84 state = self._parse_json(self._search_regex(
85 r'data-cbsvideoui-options=(["\'])(?P<json>{.+?})\1', webpage,
86 'playlist JSON info', group='json'), video_id)['state']
87 item = state['playlist'][state['pid']]
89 return self._extract_video_info(item['mpxRefId'], 'cbsnews')
92 class CBSNewsLiveVideoIE(InfoExtractor):
93 IE_NAME = 'cbsnews:livevideo'
94 IE_DESC = 'CBS News Live Videos'
95 _VALID_URL = r'https?://(?:www\.)?cbsnews\.com/live/video/(?P<id>[^/?#]+)'
97 # Live videos get deleted soon. See http://www.cbsnews.com/live/ for the latest examples
99 'url': 'http://www.cbsnews.com/live/video/clinton-sanders-prepare-to-face-off-in-nh/',
101 'id': 'clinton-sanders-prepare-to-face-off-in-nh',
103 'title': 'Clinton, Sanders Prepare To Face Off In NH',
106 'skip': 'Video gone',
109 def _real_extract(self, url):
110 display_id = self._match_id(url)
112 video_info = self._download_json(
113 'http://feeds.cbsn.cbsnews.com/rundown/story', display_id, query={
115 'dvr_slug': display_id,
118 formats = self._extract_akamai_formats(video_info['url'], display_id)
119 self._sort_formats(formats)
123 'display_id': display_id,
124 'title': video_info['headline'],
125 'thumbnail': video_info.get('thumbnail_url_hd') or video_info.get('thumbnail_url_sd'),
126 'duration': parse_duration(video_info.get('segmentDur')),