6 import xml
.etree
.ElementTree
8 from .common
import InfoExtractor
26 class CBCIE(InfoExtractor
):
28 _VALID_URL
= r
'https?://(?:www\.)?cbc\.ca/(?!player/)(?:[^/]+/)+(?P<id>[^/?#]+)'
31 'url': 'http://www.cbc.ca/22minutes/videos/clips-season-23/don-cherry-play-offs',
32 'md5': '97e24d09672fc4cf56256d6faa6c25bc',
36 'title': 'Don Cherry – All-Stars',
37 'description': 'Don Cherry has a bee in his bonnet about AHL player John Scott because that guy’s got heart.',
38 'timestamp': 1454463000,
39 'upload_date': '20160203',
40 'uploader': 'CBCC-NEW',
42 'skip': 'Geo-restricted to Canada',
44 # with clipId, feed available via tpfeed.cbc.ca and feed.theplatform.com
45 'url': 'http://www.cbc.ca/22minutes/videos/22-minutes-update/22-minutes-update-episode-4',
46 'md5': '162adfa070274b144f4fdc3c3b8207db',
50 'title': '22 Minutes Update: What Not To Wear Quebec',
51 'description': "This week's latest Canadian top political story is What Not To Wear Quebec.",
52 'upload_date': '20131025',
53 'uploader': 'CBCC-NEW',
54 'timestamp': 1382717907,
56 'skip': 'No longer available',
58 # with clipId, feed only available via tpfeed.cbc.ca
59 'url': 'http://www.cbc.ca/archives/entry/1978-robin-williams-freestyles-on-90-minutes-live',
60 'md5': '0274a90b51a9b4971fe005c63f592f12',
64 'title': 'Robin Williams freestyles on 90 Minutes Live',
65 'description': 'Wacky American comedian Robin Williams shows off his infamous "freestyle" comedic talents while being interviewed on CBC\'s 90 Minutes Live.',
66 'upload_date': '19780210',
67 'uploader': 'CBCC-NEW',
68 'timestamp': 255977160,
70 'skip': '404 Not Found',
73 'url': 'http://www.cbc.ca/natureofthings/blog/birds-eye-view-from-vancouvers-burrard-street-bridge-how-we-got-the-shot',
75 'md5': '377572d0b49c4ce0c9ad77470e0b96b4',
79 'title': 'An Eagle\'s-Eye View Off Burrard Bridge',
80 'description': 'Hercules the eagle flies from Vancouver\'s Burrard Bridge down to a nearby park with a mini-camera strapped to his back.',
81 'upload_date': '20160201',
82 'timestamp': 1454342820,
83 'uploader': 'CBCC-NEW',
86 'md5': '415a0e3f586113894174dfb31aa5bb1a',
90 'title': 'Fly like an eagle!',
91 'description': 'Eagle equipped with a mini camera flies from the world\'s tallest tower',
92 'upload_date': '20150315',
93 'timestamp': 1426443984,
94 'uploader': 'CBCC-NEW',
97 'skip': 'Geo-restricted to Canada',
99 # multiple CBC.APP.Caffeine.initInstance(...)
100 'url': 'http://www.cbc.ca/news/canada/calgary/dog-indoor-exercise-winter-1.3928238',
102 'title': 'Keep Rover active during the deep freeze with doggie pushups and other fun indoor tasks', # FIXME
103 'id': 'dog-indoor-exercise-winter-1.3928238',
104 'description': 'md5:c18552e41726ee95bd75210d1ca9194c',
106 'playlist_mincount': 6,
110 def suitable(cls
, url
):
111 return False if CBCPlayerIE
.suitable(url
) else super(CBCIE
, cls
).suitable(url
)
113 def _extract_player_init(self
, player_init
, display_id
):
114 player_info
= self
._parse
_json
(player_init
, display_id
, js_to_json
)
115 media_id
= player_info
.get('mediaId')
117 clip_id
= player_info
['clipId']
118 feed
= self
._download
_json
(
119 'http://tpfeed.cbc.ca/f/ExhSPC/vms_5akSXx4Ng_Zn?byCustomValue={:mpsReleases}{%s}' % clip_id
,
120 clip_id
, fatal
=False)
122 media_id
= try_get(feed
, lambda x
: x
['entries'][0]['guid'], compat_str
)
124 media_id
= self
._download
_json
(
125 'http://feed.theplatform.com/f/h9dtGB/punlNGjMlc1F?fields=id&byContent=byReleases%3DbyId%253D' + clip_id
,
126 clip_id
)['entries'][0]['id'].split('/')[-1]
127 return self
.url_result('cbcplayer:%s' % media_id
, 'CBCPlayer', media_id
)
129 def _real_extract(self
, url
):
130 display_id
= self
._match
_id
(url
)
131 webpage
= self
._download
_webpage
(url
, display_id
)
132 title
= (self
._og
_search
_title
(webpage
, default
=None)
133 or self
._html
_search
_meta
('twitter:title', webpage
, 'title', default
=None)
134 or self
._html
_extract
_title
(webpage
))
136 self
._extract
_player
_init
(player_init
, display_id
)
137 for player_init
in re
.findall(r
'CBC\.APP\.Caffeine\.initInstance\(({.+?})\);', webpage
)]
140 r
'<iframe[^>]+src="[^"]+?mediaId=(\d+)"',
141 r
'<div[^>]+\bid=["\']player
-(\d
+)',
142 r'guid
["\']\s*:\s*["\'](\d
+)'):
143 media_ids.extend(re.findall(media_id_re, webpage))
145 self.url_result('cbcplayer
:%s' % media_id, 'CBCPlayer
', media_id)
146 for media_id in orderedSet(media_ids)])
147 return self.playlist_result(
148 entries, display_id, strip_or_none(title),
149 self._og_search_description(webpage))
152 class CBCPlayerIE(InfoExtractor):
153 IE_NAME = 'cbc
.ca
:player
'
154 _VALID_URL = r'(?
:cbcplayer
:|https?
://(?
:www\
.)?cbc\
.ca
/(?
:player
/play
/|i
/caffeine
/syndicate
/\?mediaId
=))(?P
<id>(?
:\d\
.)?\d
+)'
156 'url
': 'http
://www
.cbc
.ca
/player
/play
/2683190193',
157 'md5
': '64d25f841ddf4ddb28a235338af32e2c
',
161 'title
': 'Gerry Runs a Sweat Shop
',
162 'description
': 'md5
:b457e1c01e8ff408d9d801c1c2cd29b0
',
163 'timestamp
': 1455071400,
164 'upload_date
': '20160210',
165 'uploader
': 'CBCC
-NEW
',
167 'skip
': 'Geo
-restricted to Canada
and no longer available
',
169 'url
': 'http
://www
.cbc
.ca
/i
/caffeine
/syndicate
/?mediaId
=2657631896',
170 'md5
': 'e5e708c34ae6fca156aafe17c43e8b75
',
174 'title
': 'CBC Montreal
is organizing its first ever community hackathon
!',
175 'description
': 'md5
:dd3b692f0a139b0369943150bd1c46a9
',
176 'timestamp
': 1425704400,
177 'upload_date
': '20150307',
178 'uploader
': 'CBCC
-NEW
',
179 'thumbnail
': 'http
://thumbnails
.cbc
.ca
/maven_legacy
/thumbnails
/sonali
-karnick
-220.jpg
',
182 'categories
': ['AudioMobile
/All
in a Weekend Montreal
'],
184 'location
': 'Quebec
',
185 'series
': 'All
in a Weekend Montreal
',
186 'season
': 'Season
2015',
187 'season_number
': 2015,
188 'media_type
': 'Excerpt
',
191 'url
': 'http
://www
.cbc
.ca
/i
/caffeine
/syndicate
/?mediaId
=2164402062',
192 'md5
': '33fcd8f6719b9dd60a5e73adcb83b9f6
',
196 'title
': 'Cancer survivor four times over
',
197 'description
': 'Tim Mayer has beaten three different forms of cancer four times
in five years
.',
198 'timestamp
': 1320410746,
199 'upload_date
': '20111104',
200 'uploader
': 'CBCC
-NEW
',
201 'thumbnail
': 'https
://thumbnails
.cbc
.ca
/maven_legacy
/thumbnails
/277/67/cancer_852x480_2164412612
.jpg
',
204 'series
': 'CBC News
: Windsor at
6:00',
205 'categories
': ['News
/Canada
/Windsor
'],
206 'location
': 'Windsor
',
208 'creators
': ['Allison Johnson
'],
209 'media_type
': 'Excerpt
',
212 # Redirected from http://www.cbc.ca/player/AudioMobile/All%20in%20a%20Weekend%20Montreal/ID/2657632011/
213 'url
': 'https
://www
.cbc
.ca
/player
/play
/1.2985700',
214 'md5
': 'e5e708c34ae6fca156aafe17c43e8b75
',
218 'title
': 'CBC Montreal
is organizing its first ever community hackathon
!',
219 'description
': 'The modern technology we tend to depend on so heavily
, is never without it
\'s share of hiccups
and headaches
. Next weekend
- CBC Montreal will be getting members of the public
for its first Hackathon
.',
220 'timestamp
': 1425704400,
221 'upload_date
': '20150307',
222 'uploader
': 'CBCC
-NEW
',
223 'thumbnail
': 'http
://thumbnails
.cbc
.ca
/maven_legacy
/thumbnails
/sonali
-karnick
-220.jpg
',
226 'categories
': ['AudioMobile
/All
in a Weekend Montreal
'],
228 'location
': 'Quebec
',
229 'series
': 'All
in a Weekend Montreal
',
230 'season
': 'Season
2015',
231 'season_number
': 2015,
232 'media_type
': 'Excerpt
',
235 'url
': 'https
://www
.cbc
.ca
/player
/play
/1.1711287',
236 'md5
': '33fcd8f6719b9dd60a5e73adcb83b9f6
',
240 'title
': 'Cancer survivor four times over
',
241 'description
': 'Tim Mayer has beaten three different forms of cancer four times
in five years
.',
242 'timestamp
': 1320410746,
243 'upload_date
': '20111104',
244 'uploader
': 'CBCC
-NEW
',
245 'thumbnail
': 'https
://thumbnails
.cbc
.ca
/maven_legacy
/thumbnails
/277/67/cancer_852x480_2164412612
.jpg
',
248 'series
': 'CBC News
: Windsor at
6:00',
249 'categories
': ['News
/Canada
/Windsor
'],
250 'location
': 'Windsor
',
252 'creators
': ['Allison Johnson
'],
253 'media_type
': 'Excerpt
',
257 # These broadcasts expire after ~1 month, can find new test URL here:
258 # https://www.cbc.ca/player/news/TV%20Shows/The%20National/Latest%20Broadcast
259 'url
': 'https
://www
.cbc
.ca
/player
/play
/1.7159484',
260 'md5
': '6ed6cd0fc2ef568d2297ba68a763d455
',
262 'id': '2324213316001',
264 'title
': 'The National | School boards sue social media giants
',
265 'description
': 'md5
:4b4db69322fa32186c3ce426da07402c
',
266 'timestamp
': 1711681200,
267 'duration
': 2743.400,
268 'subtitles
': {'eng': [{'ext': 'vtt', 'protocol': 'm3u8_native'}]},
269 'thumbnail
': 'https
://thumbnails
.cbc
.ca
/maven_legacy
/thumbnails
/607/559/thumbnail
.jpeg
',
270 'uploader
': 'CBCC
-NEW
',
271 'chapters
': 'count
:5',
272 'upload_date
': '20240329',
273 'categories
': 'count
:4',
274 'series
': 'The National
- Full Show
',
276 'creators
': ['News
'],
277 'location
': 'Canada
',
278 'media_type
': 'Full Program
',
281 'url
': 'cbcplayer
:1.7159484',
282 'only_matching
': True,
284 'url
': 'cbcplayer
:2164402062',
285 'only_matching
': True,
287 'url
': 'http
://www
.cbc
.ca
/player
/play
/2657631896',
288 'only_matching
': True,
291 def _real_extract(self, url):
292 video_id = self._match_id(url)
294 webpage = self._download_webpage(f'https
://www
.cbc
.ca
/player
/play
/{video_id}
', video_id)
295 video_id = self._search_json(
296 r'window\
.__INITIAL
_STATE
__\s
*=', webpage,
297 'initial state
', video_id)['video
']['currentClip
']['mediaId
']
300 '_type
': 'url_transparent
',
301 'ie_key
': 'ThePlatform
',
303 'http
://link
.theplatform
.com
/s
/ExhSPC
/media
/guid
/2655402169/%s?mbr
=true
&formats
=MPEG4
,FLV
,MP3
' % video_id, {
304 'force_smil_url
': True
307 '_format_sort_fields
': ('res
', 'proto
') # Prioritize direct http formats over HLS
311 class CBCPlayerPlaylistIE(InfoExtractor):
312 IE_NAME = 'cbc
.ca
:player
:playlist
'
313 _VALID_URL = r'https?
://(?
:www\
.)?cbc\
.ca
/(?
:player
/)(?
!play
/)(?P
<id>[^?
#]+)'
315 'url': 'https://www.cbc.ca/player/news/TV%20Shows/The%20National/Latest%20Broadcast',
316 'playlist_mincount': 25,
318 'id': 'news/tv shows/the national/latest broadcast',
321 'url': 'https://www.cbc.ca/player/news/Canada/North',
322 'playlist_mincount': 25,
324 'id': 'news/canada/north',
328 def _real_extract(self
, url
):
329 playlist_id
= urllib
.parse
.unquote(self
._match
_id
(url
)).lower()
330 webpage
= self
._download
_webpage
(url
, playlist_id
)
331 json_content
= self
._search
_json
(
332 r
'window\.__INITIAL_STATE__\s*=', webpage
, 'initial state', playlist_id
)
335 for video_id
in traverse_obj(json_content
, (
336 'video', 'clipsByCategory', lambda k
, _
: k
.lower() == playlist_id
, 'items', ..., 'id'
338 yield self
.url_result(f
'https://www.cbc.ca/player/play/{video_id}', CBCPlayerIE
)
340 return self
.playlist_result(entries(), playlist_id
)
343 class CBCGemIE(InfoExtractor
):
344 IE_NAME
= 'gem.cbc.ca'
345 _VALID_URL
= r
'https?://gem\.cbc\.ca/(?:media/)?(?P<id>[0-9a-z-]+/s[0-9]+[a-z][0-9]+)'
347 # This is a normal, public, TV show video
348 'url': 'https://gem.cbc.ca/media/schitts-creek/s06e01',
349 'md5': '93dbb31c74a8e45b378cf13bd3f6f11e',
351 'id': 'schitts-creek/s06e01',
353 'title': 'Smoke Signals',
354 'description': 'md5:929868d20021c924020641769eb3e7f1',
355 'thumbnail': 'https://images.radio-canada.ca/v1/synps-cbc/episode/perso/cbc_schitts_creek_season_06e01_thumbnail_v01.jpg?im=Resize=(Size)',
357 'categories': ['comedy'],
358 'series': 'Schitt\'s Creek',
359 'season': 'Season 6',
361 'episode': 'Smoke Signals',
363 'episode_id': 'schitts-creek/s06e01',
365 'params': {'format': 'bv'}
,
366 'skip': 'Geo-restricted to Canada',
368 # This video requires an account in the browser, but works fine in yt-dlp
369 'url': 'https://gem.cbc.ca/media/schitts-creek/s01e01',
370 'md5': '297a9600f554f2258aed01514226a697',
372 'id': 'schitts-creek/s01e01',
374 'title': 'The Cup Runneth Over',
375 'description': 'md5:9bca14ea49ab808097530eb05a29e797',
376 'thumbnail': 'https://images.radio-canada.ca/v1/synps-cbc/episode/perso/cbc_schitts_creek_season_01e01_thumbnail_v01.jpg?im=Resize=(Size)',
377 'series': 'Schitt\'s Creek',
379 'season': 'Season 1',
381 'episode': 'The Cup Runneth Over',
382 'episode_id': 'schitts-creek/s01e01',
384 'categories': ['comedy'],
386 'params': {'format': 'bv'}
,
387 'skip': 'Geo-restricted to Canada',
389 'url': 'https://gem.cbc.ca/nadiyas-family-favourites/s01e01',
390 'only_matching': True,
393 _GEO_COUNTRIES
= ['CA']
394 _TOKEN_API_KEY
= '3f4beddd-2061-49b0-ae80-6f1f2ed65b37'
395 _NETRC_MACHINE
= 'cbcgem'
398 def _new_claims_token(self
, email
, password
):
401 'password': password
,
403 headers
= {'content-type': 'application/json'}
404 query
= {'apikey': self._TOKEN_API_KEY}
405 resp
= self
._download
_json
('https://api.loginradius.com/identity/v2/auth/login',
406 None, data
=data
, headers
=headers
, query
=query
)
407 access_token
= resp
['access_token']
410 'access_token': access_token
,
411 'apikey': self
._TOKEN
_API
_KEY
,
414 resp
= self
._download
_json
('https://cloud-api.loginradius.com/sso/jwt/api/token',
415 None, headers
=headers
, query
=query
)
416 sig
= resp
['signature']
418 data
= json
.dumps({'jwt': sig}
).encode()
419 headers
= {'content-type': 'application/json', 'ott-device-type': 'web'}
420 resp
= self
._download
_json
('https://services.radio-canada.ca/ott/cbc-api/v2/token',
421 None, data
=data
, headers
=headers
, expected_status
=426)
422 cbc_access_token
= resp
['accessToken']
424 headers
= {'content-type': 'application/json', 'ott-device-type': 'web', 'ott-access-token': cbc_access_token}
425 resp
= self
._download
_json
('https://services.radio-canada.ca/ott/cbc-api/v2/profile',
426 None, headers
=headers
, expected_status
=426)
427 return resp
['claimsToken']
429 def _get_claims_token_expiry(self
):
431 # JWT is decoded here and 'exp' field is extracted
432 # It is a Unix timestamp for when the token expires
433 b64_data
= self
._claims
_token
.split('.')[1]
434 data
= base64
.urlsafe_b64decode(b64_data
+ "==")
435 return json
.loads(data
)['exp']
437 def claims_token_expired(self
):
438 exp
= self
._get
_claims
_token
_expiry
()
439 if exp
- time
.time() < 10:
440 # It will expire in less than 10 seconds, or has already expired
444 def claims_token_valid(self
):
445 return self
._claims
_token
is not None and not self
.claims_token_expired()
447 def _get_claims_token(self
, email
, password
):
448 if not self
.claims_token_valid():
449 self
._claims
_token
= self
._new
_claims
_token
(email
, password
)
450 self
.cache
.store(self
._NETRC
_MACHINE
, 'claims_token', self
._claims
_token
)
451 return self
._claims
_token
453 def _real_initialize(self
):
454 if self
.claims_token_valid():
456 self
._claims
_token
= self
.cache
.load(self
._NETRC
_MACHINE
, 'claims_token')
458 def _find_secret_formats(self
, formats
, video_id
):
459 """ Find a valid video url and convert it to the secret variant """
460 base_format
= next((f
for f
in formats
if f
.get('vcodec') != 'none'), None)
464 base_url
= re
.sub(r
'(Manifest\(.*?),filter=[\w-]+(.*?\))', r
'\1\2', base_format
['url'])
465 url
= re
.sub(r
'(Manifest\(.*?),format=[\w-]+(.*?\))', r
'\1\2', base_url
)
467 secret_xml
= self
._download
_xml
(url
, video_id
, note
='Downloading secret XML', fatal
=False)
468 if not isinstance(secret_xml
, xml
.etree
.ElementTree
.Element
):
471 for child
in secret_xml
:
472 if child
.attrib
.get('Type') != 'video':
474 for video_quality
in child
:
475 bitrate
= int_or_none(video_quality
.attrib
.get('Bitrate'))
476 if not bitrate
or 'Index' not in video_quality
.attrib
:
478 height
= int_or_none(video_quality
.attrib
.get('MaxHeight'))
482 'format_id': join_nonempty('sec', height
),
483 # Note: \g<1> is necessary instead of \1 since bitrate is a number
484 'url': re
.sub(r
'(QualityLevels\()\d+(\))', fr
'\g<1>{bitrate}\2', base_url
),
485 'width': int_or_none(video_quality
.attrib
.get('MaxWidth')),
486 'tbr': bitrate
/ 1000.0,
490 def _real_extract(self
, url
):
491 video_id
= self
._match
_id
(url
)
492 video_info
= self
._download
_json
(
493 f
'https://services.radio-canada.ca/ott/cbc-api/v2/assets/{video_id}',
494 video_id
, expected_status
=426)
496 email
, password
= self
._get
_login
_info
()
497 if email
and password
:
498 claims_token
= self
._get
_claims
_token
(email
, password
)
499 headers
= {'x-claims-token': claims_token}
502 m3u8_info
= self
._download
_json
(video_info
['playSession']['url'], video_id
, headers
=headers
)
503 m3u8_url
= m3u8_info
.get('url')
505 if m3u8_info
.get('errorCode') == 1:
506 self
.raise_geo_restricted(countries
=['CA'])
507 elif m3u8_info
.get('errorCode') == 35:
508 self
.raise_login_required(method
='password')
509 elif m3u8_info
.get('errorCode') != 0:
510 raise ExtractorError(f
'{self.IE_NAME} said: {m3u8_info.get("errorCode")} - {m3u8_info.get("message")}')
512 formats
= self
._extract
_m
3u8_formats
(m3u8_url
, video_id
, m3u8_id
='hls')
513 self
._remove
_duplicate
_formats
(formats
)
514 formats
.extend(self
._find
_secret
_formats
(formats
, video_id
))
516 for format
in formats
:
517 if format
.get('vcodec') == 'none':
518 if format
.get('ext') is None:
519 format
['ext'] = 'm4a'
520 if format
.get('acodec') is None:
521 format
['acodec'] = 'mp4a.40.2'
523 # Put described audio at the beginning of the list, so that it
524 # isn't chosen by default, as most people won't want it.
525 if 'descriptive' in format
['format_id'].lower():
526 format
['preference'] = -2
530 'title': video_info
['title'],
531 'description': video_info
.get('description'),
532 'thumbnail': video_info
.get('image'),
533 'series': video_info
.get('series'),
534 'season_number': video_info
.get('season'),
535 'season': f
'Season {video_info.get("season")}',
536 'episode_number': video_info
.get('episode'),
537 'episode': video_info
.get('title'),
538 'episode_id': video_id
,
539 'duration': video_info
.get('duration'),
540 'categories': [video_info
.get('category')],
542 'release_timestamp': video_info
.get('airDate'),
543 'timestamp': video_info
.get('availableDate'),
547 class CBCGemPlaylistIE(InfoExtractor
):
548 IE_NAME
= 'gem.cbc.ca:playlist'
549 _VALID_URL
= r
'https?://gem\.cbc\.ca/(?:media/)?(?P<id>(?P<show>[0-9a-z-]+)/s(?P<season>[0-9]+))/?(?:[?#]|$)'
551 # TV show playlist, all public videos
552 'url': 'https://gem.cbc.ca/media/schitts-creek/s06',
553 'playlist_count': 16,
555 'id': 'schitts-creek/s06',
557 'description': 'md5:6a92104a56cbeb5818cc47884d4326a2',
558 'series': 'Schitt\'s Creek',
560 'season': 'Season 6',
561 'thumbnail': 'https://images.radio-canada.ca/v1/synps-cbc/season/perso/cbc_schitts_creek_season_06_carousel_v03.jpg?impolicy=ott&im=Resize=(_Size_)&quality=75',
564 'url': 'https://gem.cbc.ca/schitts-creek/s06',
565 'only_matching': True,
567 _API_BASE
= 'https://services.radio-canada.ca/ott/cbc-api/v2/shows/'
569 def _real_extract(self
, url
):
570 match
= self
._match
_valid
_url
(url
)
571 season_id
= match
.group('id')
572 show
= match
.group('show')
573 show_info
= self
._download
_json
(self
._API
_BASE
+ show
, season_id
, expected_status
=426)
574 season
= int(match
.group('season'))
576 season_info
= next((s
for s
in show_info
['seasons'] if s
.get('season') == season
), None)
578 if season_info
is None:
579 raise ExtractorError(f
'Couldn\'t find season {season} of {show}')
582 for episode
in season_info
['assets']:
584 '_type': 'url_transparent',
586 'url': 'https://gem.cbc.ca/media/' + episode
['id'],
588 'title': episode
.get('title'),
589 'description': episode
.get('description'),
590 'thumbnail': episode
.get('image'),
591 'series': episode
.get('series'),
592 'season_number': episode
.get('season'),
593 'season': season_info
['title'],
594 'season_id': season_info
.get('id'),
595 'episode_number': episode
.get('episode'),
596 'episode': episode
.get('title'),
597 'episode_id': episode
['id'],
598 'duration': episode
.get('duration'),
599 'categories': [episode
.get('category')],
603 tn_uri
= season_info
.get('image')
604 # the-national was observed to use a "data:image/png;base64"
605 # URI for their 'image' value. The image was 1x1, and is
606 # probably just a placeholder, so it is ignored.
607 if tn_uri
is not None and not tn_uri
.startswith('data:'):
614 'title': season_info
['title'],
615 'description': season_info
.get('description'),
616 'thumbnail': thumbnail
,
617 'series': show_info
.get('title'),
618 'season_number': season_info
.get('season'),
619 'season': season_info
['title'],
623 class CBCGemLiveIE(InfoExtractor
):
624 IE_NAME
= 'gem.cbc.ca:live'
625 _VALID_URL
= r
'https?://gem\.cbc\.ca/live(?:-event)?/(?P<id>\d+)'
628 'url': 'https://gem.cbc.ca/live/920604739687',
631 'description': 'The live TV channel and local programming from Ottawa',
632 'thumbnail': 'https://thumbnails.cbc.ca/maven_legacy/thumbnails/CBC_OTT_VMS/Live_Channel_Static_Images/Ottawa_2880x1620.jpg',
634 'id': 'AyqZwxRqh8EH',
636 'timestamp': 1492106160,
637 'upload_date': '20170413',
638 'uploader': 'CBCC-NEW',
640 'skip': 'Live might have ended',
643 'url': 'https://gem.cbc.ca/live/44',
648 'title': r
're:^Ottawa [0-9\-: ]+',
649 'description': 'The live TV channel and local programming from Ottawa',
650 'live_status': 'is_live',
651 'thumbnail': r
're:https://images.gem.cbc.ca/v1/cbc-gem/live/.*'
653 'params': {'skip_download': True}
,
654 'skip': 'Live might have ended',
657 'url': 'https://gem.cbc.ca/live-event/10835',
662 'title': r
're:^The National \| Biden’s trip wraps up, Paltrow testifies, Bird flu [0-9\-: ]+',
663 'description': 'March 24, 2023 | President Biden’s Ottawa visit ends with big pledges from both countries. Plus, Gwyneth Paltrow testifies in her ski collision trial.',
664 'live_status': 'is_live',
665 'thumbnail': r
're:https://images.gem.cbc.ca/v1/cbc-gem/live/.*',
666 'timestamp': 1679706000,
667 'upload_date': '20230325',
669 'params': {'skip_download': True}
,
670 'skip': 'Live might have ended',
674 def _real_extract(self
, url
):
675 video_id
= self
._match
_id
(url
)
676 webpage
= self
._download
_webpage
(url
, video_id
)
677 video_info
= self
._search
_nextjs
_data
(webpage
, video_id
)['props']['pageProps']['data']
679 # Two types of metadata JSON
680 if not video_info
.get('formattedIdMedia'):
681 video_info
= traverse_obj(
682 video_info
, (('freeTv', ('streams', ...)), 'items', lambda _
, v
: v
['key'] == video_id
, {dict}
),
683 get_all
=False, default
={})
685 video_stream_id
= video_info
.get('formattedIdMedia')
686 if not video_stream_id
:
687 raise ExtractorError('Couldn\'t find video metadata, maybe this livestream is now offline', expected
=True)
689 stream_data
= self
._download
_json
(
690 'https://services.radio-canada.ca/media/validation/v2/', video_id
, query
={
692 'connectionType': 'hd',
693 'deviceType': 'ipad',
694 'idMedia': video_stream_id
,
695 'multibitrate': 'true',
698 'manifestType': 'desktop',
703 'formats': self
._extract
_m
3u8_formats
(stream_data
['url'], video_id
, 'mp4', live
=True),
705 **traverse_obj(video_info
, {
707 'description': 'description',
708 'thumbnail': ('images', 'card', 'url'),
709 'timestamp': ('airDate', {parse_iso8601}
),