1 from __future__ import unicode_literals
3 from .theplatform import ThePlatformIE
12 class CBSBaseIE(ThePlatformIE):
13 def _parse_smil_subtitles(self, smil, namespace=None, subtitles_lang='en'):
14 closed_caption_e = find_xpath_attr(smil, self._xpath_ns('.//param', namespace), 'name', 'ClosedCaptionURL')
18 'url': closed_caption_e.attrib['value'],
20 } if closed_caption_e is not None and closed_caption_e.attrib.get('value') else []
23 class CBSIE(CBSBaseIE):
24 _VALID_URL = r'https?://(?:www\.)?(?:cbs\.com/shows/[^/]+/(?:video|artist)|colbertlateshow\.com/(?:video|podcasts))/[^/]+/(?P<id>[^/]+)'
27 'url': 'http://www.cbs.com/shows/garth-brooks/video/_u7W953k6la293J7EPTd9oHkSPs6Xn6_/connect-chat-feat-garth-brooks/',
29 'id': '_u7W953k6la293J7EPTd9oHkSPs6Xn6_',
30 'display_id': 'connect-chat-feat-garth-brooks',
32 'title': 'Connect Chat feat. Garth Brooks',
33 'description': 'Connect with country music singer Garth Brooks, as he chats with fans on Wednesday November 27, 2013. Be sure to tune in to Garth Brooks: Live from Las Vegas, Friday November 29, at 9/8c on CBS!',
35 'timestamp': 1385585425,
36 'upload_date': '20131127',
37 'uploader': 'CBSI-NEW',
41 'skip_download': True,
43 '_skip': 'Blocked outside the US',
45 'url': 'http://www.cbs.com/shows/liveonletterman/artist/221752/st-vincent/',
48 'display_id': 'st-vincent',
50 'title': 'Live on Letterman - St. Vincent',
51 'description': 'Live On Letterman: St. Vincent in concert from New York\'s Ed Sullivan Theater on Tuesday, July 16, 2014.',
56 'skip_download': True,
58 '_skip': 'Blocked outside the US',
60 'url': 'http://colbertlateshow.com/video/8GmB0oY0McANFvp2aEffk9jZZZ2YyXxy/the-colbeard/',
61 'only_matching': True,
63 'url': 'http://www.colbertlateshow.com/podcasts/dYSwjqPs_X1tvbV_P2FcPWRa_qT6akTC/in-the-bad-room-with-stephen/',
64 'only_matching': True,
66 TP_RELEASE_URL_TEMPLATE = 'http://link.theplatform.com/s/dJ5BDC/%s?mbr=true'
68 def _real_extract(self, url):
69 display_id = self._match_id(url)
70 webpage = self._download_webpage(url, display_id)
71 content_id = self._search_regex(
72 [r"video\.settings\.content_id\s*=\s*'([^']+)';", r"cbsplayer\.contentId\s*=\s*'([^']+)';"],
73 webpage, 'content id')
74 items_data = self._download_xml(
75 'http://can.cbs.com/thunder/player/videoPlayerService.php',
76 content_id, query={'partner': 'cbs', 'contentId': content_id})
77 video_data = xpath_element(items_data, './/item')
78 title = xpath_text(video_data, 'videoTitle', 'title', True)
82 for item in items_data.findall('.//item'):
83 pid = xpath_text(item, 'pid')
86 tp_release_url = self.TP_RELEASE_URL_TEMPLATE % pid
87 if '.m3u8' in xpath_text(item, 'contentUrl', default=''):
88 tp_release_url += '&manifest=m3u'
89 tp_formats, tp_subtitles = self._extract_theplatform_smil(
90 tp_release_url, content_id, 'Downloading %s SMIL data' % pid)
91 formats.extend(tp_formats)
92 subtitles = self._merge_subtitles(subtitles, tp_subtitles)
93 self._sort_formats(formats)
95 info = self.get_metadata('dJ5BDC/media/guid/2198311517/%s' % content_id, content_id)
98 'display_id': display_id,
100 'series': xpath_text(video_data, 'seriesTitle'),
101 'season_number': int_or_none(xpath_text(video_data, 'seasonNumber')),
102 'episode_number': int_or_none(xpath_text(video_data, 'episodeNumber')),
103 'duration': int_or_none(xpath_text(video_data, 'videoLength'), 1000),
104 'thumbnail': xpath_text(video_data, 'previewImageURL'),
106 'subtitles': subtitles,