6 from .anvato
import AnvatoIE
7 from .common
import InfoExtractor
8 from .paramountplus
import ParamountPlusIE
9 from ..networking
import HEADRequest
26 class CBSNewsBaseIE(InfoExtractor
):
38 'philadelphia': 'PHI',
44 _LOCALE_RE
= '|'.join(map(re
.escape
, _LOCALES
))
45 _ANVACK
= '5VD6Eyd6djewbCmNwBFnsJj17YAvGRwl'
47 def _get_item(self
, webpage
, display_id
):
48 return traverse_obj(self
._search
_json
(
49 r
'CBSNEWS\.defaultPayload\s*=', webpage
, 'payload', display_id
,
50 default
={}), ('items', 0, {dict}
)) or {}
52 def _get_video_url(self
, item
):
53 return traverse_obj(item
, 'video', 'video2', expected_type
=url_or_none
)
55 def _extract_playlist(self
, webpage
, playlist_id
):
56 entries
= [self
.url_result(embed_url
, CBSNewsEmbedIE
) for embed_url
in re
.findall(
57 r
'<iframe[^>]+data-src="(https?://(?:www\.)?cbsnews\.com/embed/video/[^#]*#[^"]+)"', webpage
)]
59 return self
.playlist_result(
60 entries
, playlist_id
, self
._html
_search
_meta
(['og:title', 'twitter:title'], webpage
),
61 self
._html
_search
_meta
(['og:description', 'twitter:description', 'description'], webpage
))
63 def _extract_video(self
, item
, video_url
, video_id
):
64 if mimetype2ext(item
.get('format'), default
=determine_ext(video_url
)) == 'mp4':
65 formats
= [{'url': video_url
, 'ext': 'mp4'}]
68 manifest
= self
._download
_webpage
(video_url
, video_id
, note
='Downloading m3u8 information')
70 anvato_id
= self
._search
_regex
(r
'anvato-(\d+)', manifest
, 'Anvato ID', default
=None)
71 # Prefer Anvato if available; cbsnews.com m3u8 formats are re-encoded from Anvato source
73 return self
.url_result(
74 smuggle_url(f
'anvato:{self._ANVACK}:{anvato_id}', {'token': 'default'}),
75 AnvatoIE
, url_transparent
=True, _old_archive_ids
=[make_archive_id(self
, anvato_id
)])
77 formats
, _
= self
._parse
_m
3u8_formats
_and
_subtitles
(
78 manifest
, video_url
, 'mp4', m3u8_id
='hls', video_id
=video_id
)
80 def get_subtitles(subs_url
):
84 'ext': 'dfxp', # TTAF1
86 } if url_or_none(subs_url
) else None
88 episode_meta
= traverse_obj(item
, {
89 'season_number': ('season', {int_or_none}
),
90 'episode_number': ('episode', {int_or_none}
),
91 }) if item
.get('isFullEpisode') else {}
96 **traverse_obj(item
, {
97 'title': (None, ('fulltitle', 'title')),
99 'timestamp': ('timestamp', {lambda x
: float_or_none(x
, 1000)}),
100 'duration': ('duration', {float_or_none}
),
101 'subtitles': ('captions', {get_subtitles}
),
102 'thumbnail': ('images', ('hd', 'sd'), {url_or_none}
),
103 'is_live': ('type', {lambda x
: x
== 'live'}),
109 class CBSNewsEmbedIE(CBSNewsBaseIE
):
110 IE_NAME
= 'cbsnews:embed'
111 _VALID_URL
= r
'https?://(?:www\.)?cbsnews\.com/embed/video[^#]*#(?P<id>.+)'
113 'url': 'https://www.cbsnews.com/embed/video/?v=1.c9b5b61492913d6660db0b2f03579ef25e86307a#1Vb7b9s2EP5XBAHbT6Gt98PAMKTJ0se6LVjWYWtdGBR1stlIpEBSTtwi%2F%2FvuJNkNhmHdGxgM2NL57vjd6zt%2B8PngdN%2Fyg79qeGvhzN%2FLGrS%2F%2BuBLB531V28%2B%2BO7Qg7%2Fy97r2z3xZ42NW8yLhDbA0S0KWlHnIijwKWJBHZZnHBa8Cgbpdf%2F89NM9Hi9fXifhpr8sr%2FlP848tn%2BTdXycX25zh4cdX%2FvHl6PmmPqnWQv9w8Ed%2B9GjYRim07bFEqdG%2BZVHuwTm65A7bVRrYtR5lAyMox7pigF6W4k%2By91mjspGsJ%2BwVae4%2BsvdnaO1p73HkXs%2FVisUDTGm7R8IcdnOROeq%2B19qT1amhA1VJtPenoTUgrtfKc9m7Rq8dP7nnjwOB7wg7ADdNt7VX64DWAWlKhPtmDEq22g4GF99x6Dk9E8OSsankHXqPNKDxC%2FdK7MLKTircTDgsI3mmj4OBdSq64dy7fd1x577RU1rt4cvMtOaulFYOd%2FLewRWvDO9lIgXFpZSnkZmjbv5SxKTPoQXClFbpsf%2Fhb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2FkOE833sfeG%2Ff5cfHtEFNXgYes0%2FXj7aGivUgJ9XpusCtoNcNYVVnJVrrDo0OmJAutHCpuZul4W9lLcfy7BnuLPT02%2ByXsCTk%2B9zhzswIN04YueNSK%2BPtM0jS88QdLqSLJDTLsuGZJNolm2yO0PXh3UPnz9Ix5bfIAqxPjvETQsDCEiPG4QbqNyhBZISxybLnZYCrW5H3Axp690%2F0BJdXtDZ5ITuM4xj3f4oUHGzc5JeJmZKpp%2FjwKh4wMV%2FV1yx3emLoR0MwbG4K%2F%2BZgVep3PnzXGDHZ6a3i%2Fk%2BJrONDN13%2Bnq6tBTYk4o7cLGhBtqCC4KwacGHpEVuoH5JNro%2FE6JfE6d5RydbiR76k%2BW5wioDHBIjw1euhHjUGRB0y5A97KoaPx6MlL%2BwgboUVtUFRI%2FLemgTpdtF59ii7pab08kuPcfWzs0l%2FRI5takWnFpka0zOgWRtYcuf9aIxZMxlwr6IiGpsb6j2DQUXPl%2FimXI599Ev7fWjoPD78A',
115 'id': '6ZP4cXvo9FaX3VLH7MF4CgY30JFpY_GA',
117 'title': 'Cops investigate gorilla incident at Cincinnati Zoo',
118 'description': 'md5:fee7441ab8aaeb3c693482394738102b',
120 'timestamp': 1464719713,
121 'upload_date': '20160531',
122 'thumbnail': r
're:^https?://.*\.jpg$',
124 'params': {'skip_download': 'm3u8'},
127 def _real_extract(self
, url
):
128 item
= traverse_obj(self
._parse
_json
(zlib
.decompress(base64
.b64decode(
129 urllib
.parse
.unquote(self
._match
_id
(url
))),
130 -zlib
.MAX_WBITS
).decode(), None), ('video', 'items', 0, {dict}
)) or {}
132 video_id
= item
['mpxRefId']
133 video_url
= self
._get
_video
_url
(item
)
135 # Old embeds redirect user to ParamountPlus but most links are 404
136 pplus_url
= f
'https://www.paramountplus.com/shows/video/{video_id}'
138 self
._request
_webpage
(HEADRequest(pplus_url
), video_id
)
139 return self
.url_result(pplus_url
, ParamountPlusIE
)
140 except ExtractorError
:
141 self
.raise_no_formats('This video is no longer available', True, video_id
)
143 return self
._extract
_video
(item
, video_url
, video_id
)
146 class CBSNewsIE(CBSNewsBaseIE
):
149 _VALID_URL
= r
'https?://(?:www\.)?cbsnews\.com/(?:news|video)/(?P<id>[\w-]+)'
154 'url': 'http://www.cbsnews.com/news/artificial-intelligence-positioned-to-be-a-game-changer/',
156 'id': 'Y_nf_aEg6WwO9OLAq0MpKaPgfnBUxfW4',
158 'title': 'Artificial Intelligence, real-life applications',
159 'description': 'md5:a7aaf27f1b4777244de8b0b442289304',
160 'thumbnail': r
're:^https?://.*\.jpg$',
162 'uploader': 'CBSI-NEW',
163 'timestamp': 1476046464,
164 'upload_date': '20161009',
166 'skip': 'This video is no longer available',
169 'url': 'https://www.cbsnews.com/video/fort-hood-shooting-army-downplays-mental-illness-as-cause-of-attack/',
171 'id': 'SNJBOYzXiWBOvaLsdzwH8fmtP1SCd91Y',
173 'title': 'Fort Hood shooting: Army downplays mental illness as cause of attack',
174 'description': 'md5:4a6983e480542d8b333a947bfc64ddc7',
175 'upload_date': '20140404',
176 'timestamp': 1396650660,
177 'thumbnail': r
're:^https?://.*\.jpg$',
186 'skip_download': 'm3u8',
191 'url': 'http://www.cbsnews.com/news/maria-ridulph-murder-will-the-nations-oldest-cold-case-to-go-to-trial-ever-get-solved/',
193 'id': 'maria-ridulph-murder-will-the-nations-oldest-cold-case-to-go-to-trial-ever-get-solved',
194 'title': 'Cold as Ice',
195 'description': 'Can a childhood memory solve the 1957 murder of 7-year-old Maria Ridulph?',
197 'playlist_mincount': 7,
200 'url': 'https://www.cbsnews.com/video/032823-cbs-evening-news/',
202 'id': '_2wuO7hD9LwtyM_TwSnVwnKp6kxlcXgE',
204 'title': 'CBS Evening News, March 28, 2023',
205 'description': 'md5:db20615aae54adc1d55a1fd69dc75d13',
207 'timestamp': 1680042600,
208 'upload_date': '20230328',
209 'season': 'Season 2023',
210 'season_number': 2023,
211 'episode': 'Episode 83',
212 'episode_number': 83,
213 'thumbnail': r
're:^https?://.*\.jpg$',
216 'skip_download': 'm3u8',
221 def _real_extract(self
, url
):
222 display_id
= self
._match
_id
(url
)
223 webpage
= self
._download
_webpage
(url
, display_id
)
225 playlist
= self
._extract
_playlist
(webpage
, display_id
)
229 item
= self
._get
_item
(webpage
, display_id
)
230 video_id
= item
.get('mpxRefId') or display_id
231 video_url
= self
._get
_video
_url
(item
)
233 self
.raise_no_formats('No video content was found', expected
=True, video_id
=video_id
)
235 return self
._extract
_video
(item
, video_url
, video_id
)
238 class CBSLocalBaseIE(CBSNewsBaseIE
):
239 def _real_extract(self
, url
):
240 display_id
= self
._match
_id
(url
)
241 webpage
= self
._download
_webpage
(url
, display_id
)
243 item
= self
._get
_item
(webpage
, display_id
)
244 video_id
= item
.get('mpxRefId') or display_id
246 video_url
= self
._get
_video
_url
(item
)
249 anv_params
= self
._search
_regex
(
250 r
'<iframe[^>]+\bdata-src="https?://w3\.mp\.lura\.live/player/prod/v3/anvload\.html\?key=([^"]+)"',
251 webpage
, 'Anvato URL', default
=None)
254 playlist
= self
._extract
_playlist
(webpage
, display_id
)
257 self
.raise_no_formats('No video content was found', expected
=True, video_id
=video_id
)
259 anv_data
= self
._parse
_json
(base64
.urlsafe_b64decode(f
'{anv_params}===').decode(), video_id
)
260 anvato_id
= anv_data
['v']
261 return self
.url_result(
262 smuggle_url(f
'anvato:{anv_data.get("anvack") or self._ANVACK}:{anvato_id}', {
263 'token': anv_data
.get('token') or 'default',
264 }), AnvatoIE
, url_transparent
=True, _old_archive_ids
=[make_archive_id(self
, anvato_id
)])
266 return self
._extract
_video
(item
, video_url
, video_id
)
269 class CBSLocalIE(CBSLocalBaseIE
):
270 _VALID_URL
= rf
'https?://(?:www\.)?cbsnews\.com/(?:{CBSNewsBaseIE._LOCALE_RE})/(?:live/)?video/(?P<id>[\w-]+)'
272 # Anvato video via defaultPayload JSON
273 'url': 'https://www.cbsnews.com/newyork/video/1st-cannabis-dispensary-opens-in-queens/',
277 'title': '1st cannabis dispensary opens in Queens',
278 'description': 'The dispensary is women-owned and located in Jamaica.',
281 'timestamp': 1680193657,
282 'upload_date': '20230330',
283 'categories': ['Stations\\Spoken Word\\WCBSTV', 'Content\\Google', 'Content\\News', 'Content\\News\\Local News'],
285 'thumbnail': 're:^https?://.*',
286 '_old_archive_ids': ['cbslocal 6376747'],
288 'params': {'skip_download': 'm3u8'},
290 # cbsnews.com video via defaultPayload JSON
291 'url': 'https://www.cbsnews.com/newyork/live/video/20230330171655-the-city-is-sounding-the-alarm-on-dangerous-social-media-challenges/',
293 'id': 'sJqfw7YvgSC6ant2zVmzt3y1jYKoL5J3',
295 'title': 'the city is sounding the alarm on dangerous social media challenges',
296 'description': 'md5:8eccc9b1b73be5138a52e9c4350d2cd6',
297 'thumbnail': 'https://images-cbsn.cbsnews.com/prod/2023/03/30/story_22509622_1680196925.jpg',
299 'timestamp': 1680196615,
300 'upload_date': '20230330',
302 'params': {'skip_download': 'm3u8'},
306 class CBSLocalArticleIE(CBSLocalBaseIE
):
307 _VALID_URL
= rf
'https?://(?:www\.)?cbsnews\.com/(?:{CBSNewsBaseIE._LOCALE_RE})/news/(?P<id>[\w-]+)'
309 # Anvato video via iframe embed
310 'url': 'https://www.cbsnews.com/newyork/news/mta-station-agents-leaving-their-booths-to-provide-more-direct-customer-service/',
313 'id': 'mta-station-agents-leaving-their-booths-to-provide-more-direct-customer-service',
314 'title': 'MTA station agents begin leaving their booths to provide more direct customer service',
315 'description': 'The more than 2,200 agents will provide face-to-face customer service to passengers.',
318 'url': 'https://www.cbsnews.com/losangeles/news/safety-advocates-say-fatal-car-seat-failures-are-public-health-crisis/',
319 'md5': 'f0ee3081e3843f575fccef901199b212',
323 'title': 'Safety Advocates Say Fatal Car Seat Failures Are \'Public Health Crisis\'',
324 'thumbnail': 're:^https?://.*',
325 'timestamp': 1463440500,
326 'upload_date': '20160516',
328 'skip': 'Video has been removed',
332 class CBSNewsLiveBaseIE(CBSNewsBaseIE
):
333 def _get_id(self
, url
):
334 raise NotImplementedError('This method must be implemented by subclasses')
336 def _real_extract(self
, url
):
337 video_id
= self
._get
_id
(url
)
339 raise ExtractorError('Livestream is not available', expected
=True)
341 data
= traverse_obj(self
._download
_json
(
342 'https://feeds-cbsn.cbsnews.com/2.0/rundown/', video_id
, query
={
343 'partner': 'cbsnsite',
346 }), ('navigation', 'data', 0, {dict}
))
348 video_url
= traverse_obj(data
, (('videoUrlDAI', ('videoUrl', 'base')), {url_or_none}
), get_all
=False)
350 raise UserNotLive(video_id
=video_id
)
352 formats
, subtitles
= self
._extract
_m
3u8_formats
_and
_subtitles
(video_url
, video_id
, 'mp4', m3u8_id
='hls')
357 'subtitles': subtitles
,
359 **traverse_obj(data
, {
361 'description': 'rundown_slug',
362 'thumbnail': ('images', 'thumbnail_url_hd', {url_or_none}
),
367 class CBSLocalLiveIE(CBSNewsLiveBaseIE
):
368 _VALID_URL
= rf
'https?://(?:www\.)?cbsnews\.com/(?P<id>{CBSNewsBaseIE._LOCALE_RE})/live/?(?:[?#]|$)'
370 'url': 'https://www.cbsnews.com/losangeles/live/',
375 'description': r
're:KCBS/CBSN_LA.CRISPIN.\w+.RUNDOWN \w+ \w+',
376 'thumbnail': r
're:^https?://.*\.jpg$',
377 'live_status': 'is_live',
379 'params': {'skip_download': 'm3u8'},
382 def _get_id(self
, url
):
383 return format_field(self
._LOCALES
, self
._match
_id
(url
), 'CBSN-%s')
386 class CBSNewsLiveIE(CBSNewsLiveBaseIE
):
387 IE_NAME
= 'cbsnews:live'
388 IE_DESC
= 'CBS News Livestream'
389 _VALID_URL
= r
'https?://(?:www\.)?cbsnews\.com/live/?(?:[?#]|$)'
391 'url': 'https://www.cbsnews.com/live/',
396 'description': r
're:\w+ \w+ CRISPIN RUNDOWN',
397 'thumbnail': r
're:^https?://.*\.jpg$',
398 'live_status': 'is_live',
400 'params': {'skip_download': 'm3u8'},
403 def _get_id(self
, url
):
407 class CBSNewsLiveVideoIE(InfoExtractor
):
408 IE_NAME
= 'cbsnews:livevideo'
409 IE_DESC
= 'CBS News Live Videos'
410 _VALID_URL
= r
'https?://(?:www\.)?cbsnews\.com/live/video/(?P<id>[^/?#]+)'
412 # Live videos get deleted soon. See http://www.cbsnews.com/live/ for the latest examples
414 'url': 'http://www.cbsnews.com/live/video/clinton-sanders-prepare-to-face-off-in-nh/',
416 'id': 'clinton-sanders-prepare-to-face-off-in-nh',
418 'title': 'Clinton, Sanders Prepare To Face Off In NH',
421 'skip': 'Video gone',
424 def _real_extract(self
, url
):
425 display_id
= self
._match
_id
(url
)
427 video_info
= self
._download
_json
(
428 'http://feeds.cbsn.cbsnews.com/rundown/story', display_id
, query
={
430 'dvr_slug': display_id
,
435 'display_id': display_id
,
436 'formats': self
._extract
_akamai
_formats
(video_info
['url'], display_id
),
437 **traverse_obj(video_info
, {
439 'thumbnail': ('thumbnail_url_hd', {url_or_none}
),
440 'duration': ('segmentDur', {parse_duration}
),