2 from __future__ import unicode_literals
7 from .theplatform import ThePlatformIE
8 from ..utils import remove_start
11 class CBSNewsIE(ThePlatformIE):
13 _VALID_URL = r'http://(?:www\.)?cbsnews\.com/(?:[^/]+/)+(?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,
31 'url': 'http://www.cbsnews.com/videos/fort-hood-shooting-army-downplays-mental-illness-as-cause-of-attack/',
33 'id': 'fort-hood-shooting-army-downplays-mental-illness-as-cause-of-attack',
35 'title': 'Fort Hood shooting: Army downplays mental illness as cause of attack',
36 'thumbnail': 're:^https?://.*\.jpg$',
46 'skip_download': True,
51 def _real_extract(self, url):
52 mobj = re.match(self._VALID_URL, url)
53 video_id = mobj.group('id')
55 webpage = self._download_webpage(url, video_id)
57 video_info = json.loads(self._html_search_regex(
58 r'(?:<ul class="media-list items" id="media-related-items"><li data-video-info|<div id="cbsNewsVideoPlayer" data-video-player-options)=\'({.+?})\'',
59 webpage, 'video JSON info'))
61 item = video_info['item'] if 'item' in video_info else video_info
62 title = item.get('articleTitle') or item.get('hed')
63 duration = item.get('duration')
64 thumbnail = item.get('mediaImage') or item.get('thumbnail')
67 if 'mpxRefId' in video_info:
70 'url': 'http://www.cbsnews.com/videos/captions/%s.adb_xml' % video_info['mpxRefId'],
74 for format_id in ['RtmpMobileLow', 'RtmpMobileHigh', 'Hls', 'RtmpDesktop']:
75 pid = item.get('media' + format_id)
78 release_url = 'http://link.theplatform.com/s/dJ5BDC/%s?format=SMIL&mbr=true' % pid
79 tp_formats, tp_subtitles = self._extract_theplatform_smil(release_url, video_id, 'Downloading %s SMIL data' % pid)
80 formats.extend(tp_formats)
81 subtitles = self._merge_subtitles(subtitles, tp_subtitles)
82 self._sort_formats(formats)
87 'thumbnail': thumbnail,
90 'subtitles': subtitles,