2 from __future__ import unicode_literals
4 from .common import InfoExtractor
5 from .theplatform import ThePlatformIE
12 class CBSNewsIE(ThePlatformIE):
14 _VALID_URL = r'http://(?: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,
32 'url': 'http://www.cbsnews.com/videos/fort-hood-shooting-army-downplays-mental-illness-as-cause-of-attack/',
34 'id': 'fort-hood-shooting-army-downplays-mental-illness-as-cause-of-attack',
36 'title': 'Fort Hood shooting: Army downplays mental illness as cause of attack',
37 'thumbnail': 're:^https?://.*\.jpg$',
47 'skip_download': True,
52 def _parse_smil_subtitles(self, smil, namespace=None, subtitles_lang='en'):
53 closed_caption_e = find_xpath_attr(smil, self._xpath_ns('.//param', namespace), 'name', 'ClosedCaptionURL')
57 'url': closed_caption_e.attrib['value'],
59 } if closed_caption_e is not None and closed_caption_e.attrib.get('value') else []
61 def _real_extract(self, url):
62 video_id = self._match_id(url)
64 webpage = self._download_webpage(url, video_id)
66 video_info = self._parse_json(self._html_search_regex(
67 r'(?:<ul class="media-list items" id="media-related-items"><li data-video-info|<div id="cbsNewsVideoPlayer" data-video-player-options)=\'({.+?})\'',
68 webpage, 'video JSON info'), video_id)
70 item = video_info['item'] if 'item' in video_info else video_info
71 title = item.get('articleTitle') or item.get('hed')
72 duration = item.get('duration')
73 thumbnail = item.get('mediaImage') or item.get('thumbnail')
77 for format_id in ['RtmpMobileLow', 'RtmpMobileHigh', 'Hls', 'RtmpDesktop']:
78 pid = item.get('media' + format_id)
81 release_url = 'http://link.theplatform.com/s/dJ5BDC/%s?format=SMIL&mbr=true' % pid
82 tp_formats, tp_subtitles = self._extract_theplatform_smil(release_url, video_id, 'Downloading %s SMIL data' % pid)
83 formats.extend(tp_formats)
84 subtitles = self._merge_subtitles(subtitles, tp_subtitles)
85 self._sort_formats(formats)
90 'thumbnail': thumbnail,
93 'subtitles': subtitles,
97 class CBSNewsLiveVideoIE(InfoExtractor):
98 IE_DESC = 'CBS News Live Videos'
99 _VALID_URL = r'http://(?:www\.)?cbsnews\.com/live/video/(?P<id>[\da-z_-]+)'
102 'url': 'http://www.cbsnews.com/live/video/clinton-sanders-prepare-to-face-off-in-nh/',
104 'id': 'clinton-sanders-prepare-to-face-off-in-nh',
106 'title': 'Clinton, Sanders Prepare To Face Off In NH',
111 def _real_extract(self, url):
112 video_id = self._match_id(url)
114 webpage = self._download_webpage(url, video_id)
116 video_info = self._parse_json(self._html_search_regex(
117 r'data-story-obj=\'({.+?})\'', webpage, 'video JSON info'), video_id)['story']
119 hdcore_sign = 'hdcore=3.3.1'
120 f4m_formats = self._extract_f4m_formats(video_info['url'] + '&' + hdcore_sign, video_id)
122 for entry in f4m_formats:
123 # URLs without the extra param induce an 404 error
124 entry.update({'extra_param_to_segment_url': hdcore_sign})
128 'title': video_info['headline'],
129 'thumbnail': video_info.get('thumbnail_url_hd') or video_info.get('thumbnail_url_sd'),
130 'duration': parse_duration(video_info.get('segmentDur')),
131 'formats': f4m_formats,