1 from __future__
import unicode_literals
3 from .theplatform
import ThePlatformFeedIE
15 class CBSBaseIE(ThePlatformFeedIE
):
16 def _parse_smil_subtitles(self
, smil
, namespace
=None, subtitles_lang
='en'):
18 for k
, ext
in [('sMPTE-TTCCURL', 'tt'), ('ClosedCaptionURL', 'ttml'), ('webVTTCaptionURL', 'vtt')]:
19 cc_e
= find_xpath_attr(smil
, self
._xpath
_ns
('.//param', namespace
), 'name', k
)
21 cc_url
= cc_e
.get('value')
23 subtitles
.setdefault(subtitles_lang
, []).append({
29 def _extract_common_video_info(self
, content_id
, asset_types
, mpx_acc
, extra_info
):
30 tp_path
= 'dJ5BDC/media/guid/%d/%s' % (mpx_acc
, content_id
)
31 tp_release_url
= f
'https://link.theplatform.com/s/{tp_path}'
32 info
= self
._extract
_theplatform
_metadata
(tp_path
, content_id
)
34 formats
, subtitles
= [], {}
36 for asset_type
, query
in asset_types
.items():
38 tp_formats
, tp_subtitles
= self
._extract
_theplatform
_smil
(
39 update_url_query(tp_release_url
, query
), content_id
,
40 'Downloading %s SMIL data' % asset_type
)
41 except ExtractorError
as e
:
43 if asset_type
!= 'fallback':
45 query
['formats'] = '' # blank query to check if expired
47 tp_formats
, tp_subtitles
= self
._extract
_theplatform
_smil
(
48 update_url_query(tp_release_url
, query
), content_id
,
49 'Downloading %s SMIL data, trying again with another format' % asset_type
)
50 except ExtractorError
as e
:
53 formats
.extend(tp_formats
)
54 subtitles
= self
._merge
_subtitles
(subtitles
, tp_subtitles
)
55 if last_e
and not formats
:
56 self
.raise_no_formats(last_e
, True, content_id
)
57 self
._sort
_formats
(formats
)
62 'subtitles': subtitles
,
64 info
.update({k: v for k, v in extra_info.items() if v is not None}
)
67 def _extract_video_info(self
, *args
, **kwargs
):
68 # Extract assets + metadata and call _extract_common_video_info
69 raise NotImplementedError('This method must be implemented by subclasses')
71 def _real_extract(self
, url
):
72 return self
._extract
_video
_info
(self
._match
_id
(url
))
75 class CBSIE(CBSBaseIE
):
79 https?://(?:www\.)?(?:
80 cbs\.com/(?:shows/[^/]+/video|movies/[^/]+)/|
81 colbertlateshow\.com/(?:video|podcasts)/)
84 # All tests are blocked outside US
86 'url': 'https://www.cbs.com/shows/garth-brooks/video/_u7W953k6la293J7EPTd9oHkSPs6Xn6_/connect-chat-feat-garth-brooks/',
88 'id': '_u7W953k6la293J7EPTd9oHkSPs6Xn6_',
90 'title': 'Connect Chat feat. Garth Brooks',
91 '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!',
93 'timestamp': 1385585425,
94 'upload_date': '20131127',
95 'uploader': 'CBSI-NEW',
99 'skip_download': True,
102 'url': 'https://www.cbs.com/shows/the-late-show-with-stephen-colbert/video/60icOhMb9NcjbcWnF_gub9XXHdeBcNk2/the-late-show-6-23-21-christine-baranski-joy-oladokun-',
104 'id': '60icOhMb9NcjbcWnF_gub9XXHdeBcNk2',
105 'title': 'The Late Show - 6/23/21 (Christine Baranski, Joy Oladokun)',
106 'timestamp': 1624507140,
107 'description': 'md5:e01af24e95c74d55e8775aef86117b95',
108 'uploader': 'CBSI-NEW',
109 'upload_date': '20210624',
112 'ignore_no_formats_error': True,
113 'skip_download': True,
115 'expected_warnings': [
116 'This content expired on', 'No video formats found', 'Requested format is not available'],
118 'url': 'http://colbertlateshow.com/video/8GmB0oY0McANFvp2aEffk9jZZZ2YyXxy/the-colbeard/',
119 'only_matching': True,
121 'url': 'http://www.colbertlateshow.com/podcasts/dYSwjqPs_X1tvbV_P2FcPWRa_qT6akTC/in-the-bad-room-with-stephen/',
122 'only_matching': True,
125 def _extract_video_info(self
, content_id
, site
='cbs', mpx_acc
=2198311517):
126 items_data
= self
._download
_xml
(
127 'https://can.cbs.com/thunder/player/videoPlayerService.php',
128 content_id
, query
={'partner': site, 'contentId': content_id}
)
129 video_data
= xpath_element(items_data
, './/item')
130 title
= xpath_text(video_data
, 'videoTitle', 'title') or xpath_text(video_data
, 'videotitle', 'title')
134 for item
in items_data
.findall('.//item'):
135 asset_type
= xpath_text(item
, 'assetType')
138 'assetTypes': asset_type
,
141 # fallback for content_ids that videoPlayerService doesn't return anything for
142 asset_type
= 'fallback'
143 query
['formats'] = 'M3U+none,MPEG4,M3U+appleHlsEncryption,MP3'
144 del query
['assetTypes']
145 if asset_type
in asset_types
:
147 elif any(excluded
in asset_type
for excluded
in ('HLS_FPS', 'DASH_CENC', 'OnceURL')):
148 if 'DASH_CENC' in asset_type
:
151 if asset_type
.startswith('HLS') or 'StreamPack' in asset_type
:
152 query
['formats'] = 'MPEG4,M3U'
153 elif asset_type
in ('RTMP', 'WIFI', '3G'):
154 query
['formats'] = 'MPEG4,FLV'
155 asset_types
[asset_type
] = query
157 if not asset_types
and has_drm
:
158 self
.report_drm(content_id
)
160 return self
._extract
_common
_video
_info
(content_id
, asset_types
, mpx_acc
, extra_info
={
162 'series': xpath_text(video_data
, 'seriesTitle'),
163 'season_number': int_or_none(xpath_text(video_data
, 'seasonNumber')),
164 'episode_number': int_or_none(xpath_text(video_data
, 'episodeNumber')),
165 'duration': int_or_none(xpath_text(video_data
, 'videoLength'), 1000),
166 'thumbnail': url_or_none(xpath_text(video_data
, 'previewImageURL')),