2 from __future__ import unicode_literals
7 from .common import InfoExtractor
8 from ..utils import remove_start
11 class CBSNewsIE(InfoExtractor):
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$',
41 'skip_download': True,
46 def _real_extract(self, url):
47 mobj = re.match(self._VALID_URL, url)
48 video_id = mobj.group('id')
50 webpage = self._download_webpage(url, video_id)
52 video_info = json.loads(self._html_search_regex(
53 r'(?:<ul class="media-list items" id="media-related-items"><li data-video-info|<div id="cbsNewsVideoPlayer" data-video-player-options)=\'({.+?})\'',
54 webpage, 'video JSON info'))
56 item = video_info['item'] if 'item' in video_info else video_info
57 title = item.get('articleTitle') or item.get('hed')
58 duration = item.get('duration')
59 thumbnail = item.get('mediaImage') or item.get('thumbnail')
62 for format_id in ['RtmpMobileLow', 'RtmpMobileHigh', 'Hls', 'RtmpDesktop']:
63 uri = item.get('media' + format_id + 'URI')
66 uri = remove_start(uri, '{manifest:none}')
69 'format_id': format_id,
71 if uri.startswith('rtmp'):
73 r'{slistFilePath}', '',
74 uri.split('<break>')[-1].split('{break}')[-1])
76 r'{manifest:.+}.*$', '', play_path)
78 'app': 'ondemand?auth=cbs',
79 'play_path': 'mp4:' + play_path,
80 'player_url': 'http://www.cbsnews.com/[[IMPORT]]/vidtech.cbsinteractive.com/player/3_3_0/CBSI_PLAYER_HD.swf',
81 'page_url': 'http://www.cbsnews.com',
84 elif uri.endswith('.m3u8'):
91 'thumbnail': thumbnail,