1 from __future__ import unicode_literals
3 from .theplatform import ThePlatformIE
13 class CBSBaseIE(ThePlatformIE):
14 def _parse_smil_subtitles(self, smil, namespace=None, subtitles_lang='en'):
15 closed_caption_e = find_xpath_attr(smil, self._xpath_ns('.//param', namespace), 'name', 'ClosedCaptionURL')
19 'url': closed_caption_e.attrib['value'],
21 } if closed_caption_e is not None and closed_caption_e.attrib.get('value') else []
24 class CBSIE(CBSBaseIE):
25 _VALID_URL = r'https?://(?:www\.)?(?:cbs\.com/shows/[^/]+/(?:video|artist)|colbertlateshow\.com/(?:video|podcasts))/[^/]+/(?P<id>[^/]+)'
28 'url': 'http://www.cbs.com/shows/garth-brooks/video/_u7W953k6la293J7EPTd9oHkSPs6Xn6_/connect-chat-feat-garth-brooks/',
30 'id': '_u7W953k6la293J7EPTd9oHkSPs6Xn6_',
31 'display_id': 'connect-chat-feat-garth-brooks',
33 'title': 'Connect Chat feat. Garth Brooks',
34 '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!',
39 'skip_download': True,
41 '_skip': 'Blocked outside the US',
43 'url': 'http://www.cbs.com/shows/liveonletterman/artist/221752/st-vincent/',
46 'display_id': 'st-vincent',
48 'title': 'Live on Letterman - St. Vincent',
49 'description': 'Live On Letterman: St. Vincent in concert from New York\'s Ed Sullivan Theater on Tuesday, July 16, 2014.',
54 'skip_download': True,
56 '_skip': 'Blocked outside the US',
58 'url': 'http://colbertlateshow.com/video/8GmB0oY0McANFvp2aEffk9jZZZ2YyXxy/the-colbeard/',
59 'only_matching': True,
61 'url': 'http://www.colbertlateshow.com/podcasts/dYSwjqPs_X1tvbV_P2FcPWRa_qT6akTC/in-the-bad-room-with-stephen/',
62 'only_matching': True,
64 TP_RELEASE_URL_TEMPLATE = 'http://link.theplatform.com/s/dJ5BDC/%s?manifest=m3u&mbr=true'
66 def _real_extract(self, url):
67 display_id = self._match_id(url)
68 webpage = self._download_webpage(url, display_id)
69 content_id = self._search_regex(
70 [r"video\.settings\.content_id\s*=\s*'([^']+)';", r"cbsplayer\.contentId\s*=\s*'([^']+)';"],
71 webpage, 'content id')
72 items_data = self._download_xml(
73 'http://can.cbs.com/thunder/player/videoPlayerService.php',
74 content_id, query={'partner': 'cbs', 'contentId': content_id})
75 video_data = xpath_element(items_data, './/item')
76 title = xpath_text(video_data, 'videoTitle', 'title', True)
80 for item in items_data.findall('.//item'):
81 pid = xpath_text(item, 'pid')
85 tp_formats, tp_subtitles = self._extract_theplatform_smil(
86 self.TP_RELEASE_URL_TEMPLATE % pid, content_id, 'Downloading %s SMIL data' % pid)
87 except ExtractorError:
89 formats.extend(tp_formats)
90 subtitles = self._merge_subtitles(subtitles, tp_subtitles)
91 self._sort_formats(formats)
93 info = self.get_metadata('dJ5BDC/media/guid/2198311517/%s' % content_id, content_id)
96 'display_id': display_id,
98 'series': xpath_text(video_data, 'seriesTitle'),
99 'season_number': int_or_none(xpath_text(video_data, 'seasonNumber')),
100 'episode_number': int_or_none(xpath_text(video_data, 'episodeNumber')),
101 'duration': int_or_none(xpath_text(video_data, 'videoLength'), 1000),
102 'thumbnail': xpath_text(video_data, 'previewImageURL'),
104 'subtitles': subtitles,