7 from .anvato
import AnvatoIE
8 from .common
import InfoExtractor
9 from .paramountplus
import ParamountPlusIE
10 from ..networking
import HEADRequest
27 class CBSNewsBaseIE(InfoExtractor
):
39 'philadelphia': 'PHI',
45 _LOCALE_RE
= '|'.join(map(re
.escape
, _LOCALES
))
46 _ANVACK
= '5VD6Eyd6djewbCmNwBFnsJj17YAvGRwl'
48 def _get_item(self
, webpage
, display_id
):
49 return traverse_obj(self
._search
_json
(
50 r
'CBSNEWS\.defaultPayload\s*=', webpage
, 'payload', display_id
,
51 default
={}), ('items', 0, {dict}
)) or {}
53 def _get_video_url(self
, item
):
54 return traverse_obj(item
, 'video', 'video2', expected_type
=url_or_none
)
56 def _extract_playlist(self
, webpage
, playlist_id
):
57 entries
= [self
.url_result(embed_url
, CBSNewsEmbedIE
) for embed_url
in re
.findall(
58 r
'<iframe[^>]+data-src="(https?://(?:www\.)?cbsnews\.com/embed/video/[^#]*#[^"]+)"', webpage
)]
60 return self
.playlist_result(
61 entries
, playlist_id
, self
._html
_search
_meta
(['og:title', 'twitter:title'], webpage
),
62 self
._html
_search
_meta
(['og:description', 'twitter:description', 'description'], webpage
))
64 def _extract_video(self
, item
, video_url
, video_id
):
65 if mimetype2ext(item
.get('format'), default
=determine_ext(video_url
)) == 'mp4':
66 formats
= [{'url': video_url
, 'ext': 'mp4'}]
69 manifest
= self
._download
_webpage
(video_url
, video_id
, note
='Downloading m3u8 information')
71 anvato_id
= self
._search
_regex
(r
'anvato-(\d+)', manifest
, 'Anvato ID', default
=None)
72 # Prefer Anvato if available; cbsnews.com m3u8 formats are re-encoded from Anvato source
74 return self
.url_result(
75 smuggle_url(f
'anvato:{self._ANVACK}:{anvato_id}', {'token': 'default'}),
76 AnvatoIE
, url_transparent
=True, _old_archive_ids
=[make_archive_id(self
, anvato_id
)])
78 formats
, _
= self
._parse
_m
3u8_formats
_and
_subtitles
(
79 manifest
, video_url
, 'mp4', m3u8_id
='hls', video_id
=video_id
)
81 def get_subtitles(subs_url
):
85 'ext': 'dfxp', # TTAF1
87 } if url_or_none(subs_url
) else None
89 episode_meta
= traverse_obj(item
, {
90 'season_number': ('season', {int_or_none}
),
91 'episode_number': ('episode', {int_or_none}
),
92 }) if item
.get('isFullEpisode') else {}
97 **traverse_obj(item
, {
98 'title': (None, ('fulltitle', 'title')),
100 'timestamp': ('timestamp', {lambda x
: float_or_none(x
, 1000)}),
101 'duration': ('duration', {float_or_none}
),
102 'subtitles': ('captions', {get_subtitles}
),
103 'thumbnail': ('images', ('hd', 'sd'), {url_or_none}
),
104 'is_live': ('type', {lambda x
: x
== 'live'}),
110 class CBSNewsEmbedIE(CBSNewsBaseIE
):
111 IE_NAME
= 'cbsnews:embed'
112 _VALID_URL
= r
'https?://(?:www\.)?cbsnews\.com/embed/video[^#]*#(?P<id>.+)'
114 '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',
116 'id': '6ZP4cXvo9FaX3VLH7MF4CgY30JFpY_GA',
118 'title': 'Cops investigate gorilla incident at Cincinnati Zoo',
119 'description': 'md5:fee7441ab8aaeb3c693482394738102b',
121 'timestamp': 1464719713,
122 'upload_date': '20160531',
123 'thumbnail': r
're:^https?://.*\.jpg$',
125 'params': {'skip_download': 'm3u8'},
128 def _real_extract(self
, url
):
129 item
= traverse_obj(self
._parse
_json
(zlib
.decompress(base64
.b64decode(
130 urllib
.parse
.unquote(self
._match
_id
(url
))),
131 -zlib
.MAX_WBITS
).decode(), None), ('video', 'items', 0, {dict}
)) or {}
133 video_id
= item
['mpxRefId']
134 video_url
= self
._get
_video
_url
(item
)
136 # Old embeds redirect user to ParamountPlus but most links are 404
137 pplus_url
= f
'https://www.paramountplus.com/shows/video/{video_id}'
139 self
._request
_webpage
(HEADRequest(pplus_url
), video_id
)
140 return self
.url_result(pplus_url
, ParamountPlusIE
)
141 except ExtractorError
:
142 self
.raise_no_formats('This video is no longer available', True, video_id
)
144 return self
._extract
_video
(item
, video_url
, video_id
)
147 class CBSNewsIE(CBSNewsBaseIE
):
150 _VALID_URL
= r
'https?://(?:www\.)?cbsnews\.com/(?:news|video)/(?P<id>[\w-]+)'
155 'url': 'http://www.cbsnews.com/news/artificial-intelligence-positioned-to-be-a-game-changer/',
157 'id': 'Y_nf_aEg6WwO9OLAq0MpKaPgfnBUxfW4',
159 'title': 'Artificial Intelligence, real-life applications',
160 'description': 'md5:a7aaf27f1b4777244de8b0b442289304',
161 'thumbnail': r
're:^https?://.*\.jpg$',
163 'uploader': 'CBSI-NEW',
164 'timestamp': 1476046464,
165 'upload_date': '20161009',
167 'skip': 'This video is no longer available',
170 'url': 'https://www.cbsnews.com/video/fort-hood-shooting-army-downplays-mental-illness-as-cause-of-attack/',
172 'id': 'SNJBOYzXiWBOvaLsdzwH8fmtP1SCd91Y',
174 'title': 'Fort Hood shooting: Army downplays mental illness as cause of attack',
175 'description': 'md5:4a6983e480542d8b333a947bfc64ddc7',
176 'upload_date': '20140404',
177 'timestamp': 1396650660,
178 'thumbnail': r
're:^https?://.*\.jpg$',
187 'skip_download': 'm3u8',
192 'url': 'http://www.cbsnews.com/news/maria-ridulph-murder-will-the-nations-oldest-cold-case-to-go-to-trial-ever-get-solved/',
194 'id': 'maria-ridulph-murder-will-the-nations-oldest-cold-case-to-go-to-trial-ever-get-solved',
195 'title': 'Cold as Ice',
196 'description': 'Can a childhood memory solve the 1957 murder of 7-year-old Maria Ridulph?',
198 'playlist_mincount': 7,
201 'url': 'https://www.cbsnews.com/video/032823-cbs-evening-news/',
203 'id': '_2wuO7hD9LwtyM_TwSnVwnKp6kxlcXgE',
205 'title': 'CBS Evening News, March 28, 2023',
206 'description': 'md5:db20615aae54adc1d55a1fd69dc75d13',
208 'timestamp': 1680042600,
209 'upload_date': '20230328',
210 'season': 'Season 2023',
211 'season_number': 2023,
212 'episode': 'Episode 83',
213 'episode_number': 83,
214 'thumbnail': r
're:^https?://.*\.jpg$',
217 'skip_download': 'm3u8',
222 def _real_extract(self
, url
):
223 display_id
= self
._match
_id
(url
)
224 webpage
= self
._download
_webpage
(url
, display_id
)
226 playlist
= self
._extract
_playlist
(webpage
, display_id
)
230 item
= self
._get
_item
(webpage
, display_id
)
231 video_id
= item
.get('mpxRefId') or display_id
232 video_url
= self
._get
_video
_url
(item
)
234 self
.raise_no_formats('No video content was found', expected
=True, video_id
=video_id
)
236 return self
._extract
_video
(item
, video_url
, video_id
)
239 class CBSLocalBaseIE(CBSNewsBaseIE
):
240 def _real_extract(self
, url
):
241 display_id
= self
._match
_id
(url
)
242 webpage
= self
._download
_webpage
(url
, display_id
)
244 item
= self
._get
_item
(webpage
, display_id
)
245 video_id
= item
.get('mpxRefId') or display_id
247 video_url
= self
._get
_video
_url
(item
)
250 anv_params
= self
._search
_regex
(
251 r
'<iframe[^>]+\bdata-src="https?://w3\.mp\.lura\.live/player/prod/v3/anvload\.html\?key=([^"]+)"',
252 webpage
, 'Anvato URL', default
=None)
255 playlist
= self
._extract
_playlist
(webpage
, display_id
)
258 self
.raise_no_formats('No video content was found', expected
=True, video_id
=video_id
)
260 anv_data
= self
._parse
_json
(base64
.urlsafe_b64decode(f
'{anv_params}===').decode(), video_id
)
261 anvato_id
= anv_data
['v']
262 return self
.url_result(
263 smuggle_url(f
'anvato:{anv_data.get("anvack") or self._ANVACK}:{anvato_id}', {
264 'token': anv_data
.get('token') or 'default',
265 }), AnvatoIE
, url_transparent
=True, _old_archive_ids
=[make_archive_id(self
, anvato_id
)])
267 return self
._extract
_video
(item
, video_url
, video_id
)
270 class CBSLocalIE(CBSLocalBaseIE
):
271 _VALID_URL
= rf
'https?://(?:www\.)?cbsnews\.com/(?:{CBSNewsBaseIE._LOCALE_RE})/(?:live/)?video/(?P<id>[\w-]+)'
273 # Anvato video via defaultPayload JSON
274 'url': 'https://www.cbsnews.com/newyork/video/1st-cannabis-dispensary-opens-in-queens/',
278 'title': '1st cannabis dispensary opens in Queens',
279 'description': 'The dispensary is women-owned and located in Jamaica.',
282 'timestamp': 1680193657,
283 'upload_date': '20230330',
284 'categories': ['Stations\\Spoken Word\\WCBSTV', 'Content\\Google', 'Content\\News', 'Content\\News\\Local News'],
286 'thumbnail': 're:^https?://.*',
287 '_old_archive_ids': ['cbslocal 6376747'],
289 'params': {'skip_download': 'm3u8'},
291 # cbsnews.com video via defaultPayload JSON
292 'url': 'https://www.cbsnews.com/newyork/live/video/20230330171655-the-city-is-sounding-the-alarm-on-dangerous-social-media-challenges/',
294 'id': 'sJqfw7YvgSC6ant2zVmzt3y1jYKoL5J3',
296 'title': 'the city is sounding the alarm on dangerous social media challenges',
297 'description': 'md5:8eccc9b1b73be5138a52e9c4350d2cd6',
298 'thumbnail': 'https://images-cbsn.cbsnews.com/prod/2023/03/30/story_22509622_1680196925.jpg',
300 'timestamp': 1680196615,
301 'upload_date': '20230330',
303 'params': {'skip_download': 'm3u8'},
307 class CBSLocalArticleIE(CBSLocalBaseIE
):
308 _VALID_URL
= rf
'https?://(?:www\.)?cbsnews\.com/(?:{CBSNewsBaseIE._LOCALE_RE})/news/(?P<id>[\w-]+)'
310 # Anvato video via iframe embed
311 'url': 'https://www.cbsnews.com/newyork/news/mta-station-agents-leaving-their-booths-to-provide-more-direct-customer-service/',
314 'id': 'mta-station-agents-leaving-their-booths-to-provide-more-direct-customer-service',
315 'title': 'MTA station agents begin leaving their booths to provide more direct customer service',
316 'description': 'The more than 2,200 agents will provide face-to-face customer service to passengers.',
319 'url': 'https://www.cbsnews.com/losangeles/news/safety-advocates-say-fatal-car-seat-failures-are-public-health-crisis/',
320 'md5': 'f0ee3081e3843f575fccef901199b212',
324 'title': 'Safety Advocates Say Fatal Car Seat Failures Are \'Public Health Crisis\'',
325 'thumbnail': 're:^https?://.*',
326 'timestamp': 1463440500,
327 'upload_date': '20160516',
329 'skip': 'Video has been removed',
333 class CBSNewsLiveBaseIE(CBSNewsBaseIE
):
334 def _get_id(self
, url
):
335 raise NotImplementedError('This method must be implemented by subclasses')
337 def _real_extract(self
, url
):
338 video_id
= self
._get
_id
(url
)
340 raise ExtractorError('Livestream is not available', expected
=True)
342 data
= traverse_obj(self
._download
_json
(
343 'https://feeds-cbsn.cbsnews.com/2.0/rundown/', video_id
, query
={
344 'partner': 'cbsnsite',
347 }), ('navigation', 'data', 0, {dict}
))
349 video_url
= traverse_obj(data
, (('videoUrlDAI', ('videoUrl', 'base')), {url_or_none}
), get_all
=False)
351 raise UserNotLive(video_id
=video_id
)
353 formats
, subtitles
= self
._extract
_m
3u8_formats
_and
_subtitles
(video_url
, video_id
, 'mp4', m3u8_id
='hls')
358 'subtitles': subtitles
,
360 **traverse_obj(data
, {
362 'description': 'rundown_slug',
363 'thumbnail': ('images', 'thumbnail_url_hd', {url_or_none}
),
368 class CBSLocalLiveIE(CBSNewsLiveBaseIE
):
369 _VALID_URL
= rf
'https?://(?:www\.)?cbsnews\.com/(?P<id>{CBSNewsBaseIE._LOCALE_RE})/live/?(?:[?#]|$)'
371 'url': 'https://www.cbsnews.com/losangeles/live/',
376 'description': r
're:KCBS/CBSN_LA.CRISPIN.\w+.RUNDOWN \w+ \w+',
377 'thumbnail': r
're:^https?://.*\.jpg$',
378 'live_status': 'is_live',
380 'params': {'skip_download': 'm3u8'},
383 def _get_id(self
, url
):
384 return format_field(self
._LOCALES
, self
._match
_id
(url
), 'CBSN-%s')
387 class CBSNewsLiveIE(CBSNewsLiveBaseIE
):
388 IE_NAME
= 'cbsnews:live'
389 IE_DESC
= 'CBS News Livestream'
390 _VALID_URL
= r
'https?://(?:www\.)?cbsnews\.com/live/?(?:[?#]|$)'
392 'url': 'https://www.cbsnews.com/live/',
397 'description': r
're:\w+ \w+ CRISPIN RUNDOWN',
398 'thumbnail': r
're:^https?://.*\.jpg$',
399 'live_status': 'is_live',
401 'params': {'skip_download': 'm3u8'},
404 def _get_id(self
, url
):
408 class CBSNewsLiveVideoIE(InfoExtractor
):
409 IE_NAME
= 'cbsnews:livevideo'
410 IE_DESC
= 'CBS News Live Videos'
411 _VALID_URL
= r
'https?://(?:www\.)?cbsnews\.com/live/video/(?P<id>[^/?#]+)'
413 # Live videos get deleted soon. See http://www.cbsnews.com/live/ for the latest examples
415 'url': 'http://www.cbsnews.com/live/video/clinton-sanders-prepare-to-face-off-in-nh/',
417 'id': 'clinton-sanders-prepare-to-face-off-in-nh',
419 'title': 'Clinton, Sanders Prepare To Face Off In NH',
422 'skip': 'Video gone',
425 def _real_extract(self
, url
):
426 display_id
= self
._match
_id
(url
)
428 video_info
= self
._download
_json
(
429 'http://feeds.cbsn.cbsnews.com/rundown/story', display_id
, query
={
431 'dvr_slug': display_id
,
436 'display_id': display_id
,
437 'formats': self
._extract
_akamai
_formats
(video_info
['url'], display_id
),
438 **traverse_obj(video_info
, {
440 'thumbnail': ('thumbnail_url_hd', {url_or_none}
),
441 'duration': ('segmentDur', {parse_duration}
),