2 from __future__ import unicode_literals
7 from .theplatform import ThePlatformIE
10 class CBSNewsIE(ThePlatformIE):
12 _VALID_URL = r'http://(?:www\.)?cbsnews\.com/(?:[^/]+/)+(?P<id>[\da-z_-]+)'
16 'url': 'http://www.cbsnews.com/news/tesla-and-spacex-elon-musks-industrial-empire/',
18 'id': 'tesla-and-spacex-elon-musks-industrial-empire',
20 'title': 'Tesla and SpaceX: Elon Musk\'s industrial empire',
21 'thumbnail': 'http://beta.img.cbsnews.com/i/2014/03/30/60147937-2f53-4565-ad64-1bdd6eb64679/60-0330-pelley-640x360.jpg',
26 'skip_download': True,
30 'url': 'http://www.cbsnews.com/videos/fort-hood-shooting-army-downplays-mental-illness-as-cause-of-attack/',
32 'id': 'fort-hood-shooting-army-downplays-mental-illness-as-cause-of-attack',
34 'title': 'Fort Hood shooting: Army downplays mental illness as cause of attack',
35 'thumbnail': 're:^https?://.*\.jpg$',
45 'skip_download': True,
50 def _real_extract(self, url):
51 mobj = re.match(self._VALID_URL, url)
52 video_id = mobj.group('id')
54 webpage = self._download_webpage(url, video_id)
56 video_info = json.loads(self._html_search_regex(
57 r'(?:<ul class="media-list items" id="media-related-items"><li data-video-info|<div id="cbsNewsVideoPlayer" data-video-player-options)=\'({.+?})\'',
58 webpage, 'video JSON info'))
60 item = video_info['item'] if 'item' in video_info else video_info
61 title = item.get('articleTitle') or item.get('hed')
62 duration = item.get('duration')
63 thumbnail = item.get('mediaImage') or item.get('thumbnail')
66 if 'mpxRefId' in video_info:
69 'url': 'http://www.cbsnews.com/videos/captions/%s.adb_xml' % video_info['mpxRefId'],
73 for format_id in ['RtmpMobileLow', 'RtmpMobileHigh', 'Hls', 'RtmpDesktop']:
74 pid = item.get('media' + format_id)
77 release_url = 'http://link.theplatform.com/s/dJ5BDC/%s?format=SMIL&mbr=true' % pid
78 tp_formats, tp_subtitles = self._extract_theplatform_smil(release_url, video_id, 'Downloading %s SMIL data' % pid)
79 formats.extend(tp_formats)
80 subtitles = self._merge_subtitles(subtitles, tp_subtitles)
81 self._sort_formats(formats)
86 'thumbnail': thumbnail,
89 'subtitles': subtitles,