1 from .brightcove
import BrightcoveNewIE
2 from .common
import InfoExtractor
3 from .theplatform
import ThePlatformFeedIE
4 from .youtube
import YoutubeIE
8 get_element_html_by_id
,
19 class CBSBaseIE(ThePlatformFeedIE
): # XXX: Do not subclass from concrete IE
20 def _parse_smil_subtitles(self
, smil
, namespace
=None, subtitles_lang
='en'):
22 for k
, ext
in [('sMPTE-TTCCURL', 'tt'), ('ClosedCaptionURL', 'ttml'), ('webVTTCaptionURL', 'vtt')]:
23 cc_e
= find_xpath_attr(smil
, self
._xpath
_ns
('.//param', namespace
), 'name', k
)
25 cc_url
= cc_e
.get('value')
27 subtitles
.setdefault(subtitles_lang
, []).append({
33 def _extract_common_video_info(self
, content_id
, asset_types
, mpx_acc
, extra_info
):
34 tp_path
= 'dJ5BDC/media/guid/%d/%s' % (mpx_acc
, content_id
)
35 tp_release_url
= f
'https://link.theplatform.com/s/{tp_path}'
36 info
= self
._extract
_theplatform
_metadata
(tp_path
, content_id
)
38 formats
, subtitles
= [], {}
40 for asset_type
, query
in asset_types
.items():
42 tp_formats
, tp_subtitles
= self
._extract
_theplatform
_smil
(
43 update_url_query(tp_release_url
, query
), content_id
,
44 'Downloading %s SMIL data' % asset_type
)
45 except ExtractorError
as e
:
47 if asset_type
!= 'fallback':
49 query
['formats'] = '' # blank query to check if expired
51 tp_formats
, tp_subtitles
= self
._extract
_theplatform
_smil
(
52 update_url_query(tp_release_url
, query
), content_id
,
53 'Downloading %s SMIL data, trying again with another format' % asset_type
)
54 except ExtractorError
as e
:
57 formats
.extend(tp_formats
)
58 subtitles
= self
._merge
_subtitles
(subtitles
, tp_subtitles
)
59 if last_e
and not formats
:
60 self
.raise_no_formats(last_e
, True, content_id
)
65 'subtitles': subtitles
,
67 info
.update({k
: v
for k
, v
in extra_info
.items() if v
is not None})
70 def _extract_video_info(self
, *args
, **kwargs
):
71 # Extract assets + metadata and call _extract_common_video_info
72 raise NotImplementedError('This method must be implemented by subclasses')
74 def _real_extract(self
, url
):
75 return self
._extract
_video
_info
(self
._match
_id
(url
))
78 class CBSIE(CBSBaseIE
):
83 https?://(?:www\.)?(?:
84 cbs\.com/(?:shows|movies)/(?:video|[^/]+/video|[^/]+)/|
85 colbertlateshow\.com/(?:video|podcasts)/)
88 # All tests are blocked outside US
90 'url': 'https://www.cbs.com/shows/video/xrUyNLtl9wd8D_RWWAg9NU2F_V6QpB3R/',
92 'id': 'xrUyNLtl9wd8D_RWWAg9NU2F_V6QpB3R',
94 'title': 'Tough As Nails - Dreams Never Die',
95 'description': 'md5:a3535a62531cdd52b0364248a2c1ae33',
97 'timestamp': 1639015200,
98 'upload_date': '20211209',
99 'uploader': 'CBSI-NEW',
103 'skip_download': True,
105 'skip': 'Subscription required',
107 'url': 'https://www.cbs.com/shows/video/sZH1MGgomIosZgxGJ1l263MFq16oMtW1/',
109 'id': 'sZH1MGgomIosZgxGJ1l263MFq16oMtW1',
110 'title': 'The Late Show - 3/16/22 (Michael Buble, Rose Matafeo)',
111 'timestamp': 1647488100,
112 'description': 'md5:d0e6ec23c544b7fa8e39a8e6844d2439',
113 'uploader': 'CBSI-NEW',
114 'upload_date': '20220317',
117 'ignore_no_formats_error': True,
118 'skip_download': True,
120 'expected_warnings': [
121 'This content expired on', 'No video formats found', 'Requested format is not available'],
122 'skip': '404 Not Found',
124 'url': 'http://colbertlateshow.com/video/8GmB0oY0McANFvp2aEffk9jZZZ2YyXxy/the-colbeard/',
125 'only_matching': True,
127 'url': 'http://www.colbertlateshow.com/podcasts/dYSwjqPs_X1tvbV_P2FcPWRa_qT6akTC/in-the-bad-room-with-stephen/',
128 'only_matching': True,
131 def _extract_video_info(self
, content_id
, site
='cbs', mpx_acc
=2198311517):
132 items_data
= self
._download
_xml
(
133 'https://can.cbs.com/thunder/player/videoPlayerService.php',
134 content_id
, query
={'partner': site
, 'contentId': content_id
})
135 video_data
= xpath_element(items_data
, './/item')
136 title
= xpath_text(video_data
, 'videoTitle', 'title') or xpath_text(video_data
, 'videotitle', 'title')
140 for item
in items_data
.findall('.//item'):
141 asset_type
= xpath_text(item
, 'assetType')
144 'assetTypes': asset_type
,
147 # fallback for content_ids that videoPlayerService doesn't return anything for
148 asset_type
= 'fallback'
149 query
['formats'] = 'M3U+none,MPEG4,M3U+appleHlsEncryption,MP3'
150 del query
['assetTypes']
151 if asset_type
in asset_types
:
153 elif any(excluded
in asset_type
for excluded
in ('HLS_FPS', 'DASH_CENC', 'OnceURL')):
154 if 'DASH_CENC' in asset_type
:
157 if asset_type
.startswith('HLS') or 'StreamPack' in asset_type
:
158 query
['formats'] = 'MPEG4,M3U'
159 elif asset_type
in ('RTMP', 'WIFI', '3G'):
160 query
['formats'] = 'MPEG4,FLV'
161 asset_types
[asset_type
] = query
163 if not asset_types
and has_drm
:
164 self
.report_drm(content_id
)
166 return self
._extract
_common
_video
_info
(content_id
, asset_types
, mpx_acc
, extra_info
={
168 'series': xpath_text(video_data
, 'seriesTitle'),
169 'season_number': int_or_none(xpath_text(video_data
, 'seasonNumber')),
170 'episode_number': int_or_none(xpath_text(video_data
, 'episodeNumber')),
171 'duration': int_or_none(xpath_text(video_data
, 'videoLength'), 1000),
172 'thumbnail': url_or_none(xpath_text(video_data
, 'previewImageURL')),
176 class ParamountPressExpressIE(InfoExtractor
):
177 _VALID_URL
= r
'https?://(?:www\.)?paramountpressexpress\.com(?:/[\w-]+)+/(?P<yt>yt-)?video/?\?watch=(?P<id>[\w-]+)'
179 'url': 'https://www.paramountpressexpress.com/cbs-entertainment/shows/survivor/video/?watch=pnzew7e2hx',
180 'md5': '56631dbcadaab980d1fc47cb7b76cba4',
182 'id': '6322981580112',
184 'title': 'I’m Felicia',
185 'description': 'md5:88fad93f8eede1c9c8f390239e4c6290',
186 'uploader_id': '6055873637001',
187 'upload_date': '20230320',
188 'timestamp': 1679334960,
190 'thumbnail': r
're:^https://.+\.jpg',
194 'url': 'https://www.paramountpressexpress.com/cbs-entertainment/video/?watch=2s5eh8kppc',
195 'md5': 'edcb03e3210b88a3e56c05aa863e0e5b',
197 'id': '6323036027112',
199 'title': '‘Y&R’ Set Visit: Jerry O’Connell Quizzes Cast on Pre-Love Scene Rituals and More',
200 'description': 'md5:b929867a357aac5544b783d834c78383',
201 'uploader_id': '6055873637001',
202 'upload_date': '20230321',
203 'timestamp': 1679430180,
205 'thumbnail': r
're:^https://.+\.jpg',
209 'url': 'https://www.paramountpressexpress.com/paramount-plus/yt-video/?watch=OX9wJWOcqck',
213 'title': 'Rugrats | Season 2 Official Trailer | Paramount+',
214 'description': 'md5:1f7e26f5625a9f0d6564d9ad97a9f7de',
215 'uploader': 'Paramount Plus',
216 'uploader_id': '@paramountplus',
217 'uploader_url': 'http://www.youtube.com/@paramountplus',
218 'channel': 'Paramount Plus',
219 'channel_id': 'UCrRttZIypNTA1Mrfwo745Sg',
220 'channel_url': 'https://www.youtube.com/channel/UCrRttZIypNTA1Mrfwo745Sg',
221 'upload_date': '20230316',
224 'availability': 'public',
225 'live_status': 'not_live',
226 'playable_in_embed': True,
229 'channel_follower_count': int,
230 'thumbnail': 'https://i.ytimg.com/vi/OX9wJWOcqck/maxresdefault.jpg',
231 'categories': ['Entertainment'],
235 'url': 'https://www.paramountpressexpress.com/showtime/yt-video/?watch=_ljssSoDLkw',
239 'title': 'Lavell Crawford: THEE Lavell Crawford Comedy Special Official Trailer | SHOWTIME',
240 'description': 'md5:39581bcc3fd810209b642609f448af70',
241 'uploader': 'SHOWTIME',
242 'uploader_id': '@Showtime',
243 'uploader_url': 'http://www.youtube.com/@Showtime',
244 'channel': 'SHOWTIME',
245 'channel_id': 'UCtwMWJr2BFPkuJTnSvCESSQ',
246 'channel_url': 'https://www.youtube.com/channel/UCtwMWJr2BFPkuJTnSvCESSQ',
247 'upload_date': '20230209',
250 'availability': 'public',
251 'live_status': 'not_live',
252 'playable_in_embed': True,
255 'comment_count': int,
256 'channel_follower_count': int,
257 'thumbnail': 'https://i.ytimg.com/vi_webp/_ljssSoDLkw/maxresdefault.webp',
258 'categories': ['People & Blogs'],
263 def _real_extract(self
, url
):
264 display_id
, is_youtube
= self
._match
_valid
_url
(url
).group('id', 'yt')
266 return self
.url_result(display_id
, YoutubeIE
)
268 webpage
= self
._download
_webpage
(url
, display_id
)
269 video_id
= self
._search
_regex
(
270 r
'\bvideo_id\s*=\s*["\'](\d
+)["\']\s*,', webpage, 'Brightcove ID')
271 token = self._search_regex(r'\btoken\s*=\s*["\']([\w
.-]+)["\']', webpage, 'token')
273 player = extract_attributes(get_element_html_by_id('vcbrightcoveplayer', webpage) or '')
274 account_id = player.get('data-account') or '6055873637001'
275 player_id = player.get('data-player') or 'OtLKgXlO9F'
276 embed = player.get('data-embed') or 'default'
278 return self.url_result(smuggle_url(
279 f'https://players.brightcove.net/{account_id}/{player_id}_{embed}/index.html?videoId={video_id}',
280 {'token': token}), BrightcoveNewIE)