2016-02-11 12:10:32 -05:00
# coding: utf-8
from __future__ import unicode_literals
import re
from . common import InfoExtractor
2018-04-11 12:28:55 -04:00
from . . compat import (
compat_str ,
)
2016-05-20 01:53:14 -04:00
from . . utils import (
js_to_json ,
smuggle_url ,
2016-07-26 11:58:50 -04:00
try_get ,
2018-06-01 13:35:07 -04:00
orderedSet ,
2018-05-26 09:05:54 -04:00
strip_or_none ,
2016-08-25 03:49:15 -04:00
ExtractorError ,
2016-05-20 01:53:14 -04:00
)
2016-02-11 12:10:32 -05:00
class CBCIE ( InfoExtractor ) :
2016-08-25 03:49:15 -04:00
IE_NAME = ' cbc.ca '
2016-05-20 06:39:54 -04:00
_VALID_URL = r ' https?://(?:www \ .)?cbc \ .ca/(?!player/)(?:[^/]+/)+(?P<id>[^/?#]+) '
2016-02-11 12:10:32 -05:00
_TESTS = [ {
# with mediaId
' url ' : ' http://www.cbc.ca/22minutes/videos/clips-season-23/don-cherry-play-offs ' ,
2016-05-20 01:53:14 -04:00
' md5 ' : ' 97e24d09672fc4cf56256d6faa6c25bc ' ,
2016-02-11 12:10:32 -05:00
' info_dict ' : {
' id ' : ' 2682904050 ' ,
2016-05-20 01:53:14 -04:00
' ext ' : ' mp4 ' ,
2016-02-11 12:10:32 -05:00
' title ' : ' Don Cherry – All-Stars ' ,
' description ' : ' Don Cherry has a bee in his bonnet about AHL player John Scott because that guy’ s got heart. ' ,
2016-05-20 01:53:14 -04:00
' timestamp ' : 1454463000 ,
2016-02-11 12:10:32 -05:00
' upload_date ' : ' 20160203 ' ,
2016-05-20 01:53:14 -04:00
' uploader ' : ' CBCC-NEW ' ,
2016-02-11 12:10:32 -05:00
} ,
2016-07-15 12:02:26 -04:00
' skip ' : ' Geo-restricted to Canada ' ,
2016-02-11 12:10:32 -05:00
} , {
2016-07-26 11:58:50 -04:00
# with clipId, feed available via tpfeed.cbc.ca and feed.theplatform.com
' url ' : ' http://www.cbc.ca/22minutes/videos/22-minutes-update/22-minutes-update-episode-4 ' ,
' md5 ' : ' 162adfa070274b144f4fdc3c3b8207db ' ,
' info_dict ' : {
' id ' : ' 2414435309 ' ,
' ext ' : ' mp4 ' ,
' title ' : ' 22 Minutes Update: What Not To Wear Quebec ' ,
' description ' : " This week ' s latest Canadian top political story is What Not To Wear Quebec. " ,
' upload_date ' : ' 20131025 ' ,
' uploader ' : ' CBCC-NEW ' ,
' timestamp ' : 1382717907 ,
} ,
2021-09-19 18:13:26 -04:00
' skip ' : ' No longer available ' ,
2016-07-26 11:58:50 -04:00
} , {
# with clipId, feed only available via tpfeed.cbc.ca
2016-02-11 12:10:32 -05:00
' url ' : ' http://www.cbc.ca/archives/entry/1978-robin-williams-freestyles-on-90-minutes-live ' ,
2016-05-20 11:20:05 -04:00
' md5 ' : ' 0274a90b51a9b4971fe005c63f592f12 ' ,
2016-02-11 12:10:32 -05:00
' info_dict ' : {
' id ' : ' 2487345465 ' ,
2016-05-20 01:53:14 -04:00
' ext ' : ' mp4 ' ,
2016-02-11 12:10:32 -05:00
' title ' : ' Robin Williams freestyles on 90 Minutes Live ' ,
' description ' : ' Wacky American comedian Robin Williams shows off his infamous " freestyle " comedic talents while being interviewed on CBC \' s 90 Minutes Live. ' ,
2016-05-20 01:53:14 -04:00
' upload_date ' : ' 19780210 ' ,
2016-04-24 08:44:52 -04:00
' uploader ' : ' CBCC-NEW ' ,
2016-05-20 01:53:14 -04:00
' timestamp ' : 255977160 ,
2016-02-11 12:10:32 -05:00
} ,
} , {
# multiple iframes
' url ' : ' http://www.cbc.ca/natureofthings/blog/birds-eye-view-from-vancouvers-burrard-street-bridge-how-we-got-the-shot ' ,
' playlist ' : [ {
2016-05-20 01:53:14 -04:00
' md5 ' : ' 377572d0b49c4ce0c9ad77470e0b96b4 ' ,
2016-02-11 12:10:32 -05:00
' info_dict ' : {
' id ' : ' 2680832926 ' ,
2016-05-20 01:53:14 -04:00
' ext ' : ' mp4 ' ,
2016-02-11 12:10:32 -05:00
' title ' : ' An Eagle \' s-Eye View Off Burrard Bridge ' ,
' description ' : ' Hercules the eagle flies from Vancouver \' s Burrard Bridge down to a nearby park with a mini-camera strapped to his back. ' ,
2016-05-20 01:53:14 -04:00
' upload_date ' : ' 20160201 ' ,
' timestamp ' : 1454342820 ,
' uploader ' : ' CBCC-NEW ' ,
2016-02-11 12:10:32 -05:00
} ,
} , {
2016-05-20 01:53:14 -04:00
' md5 ' : ' 415a0e3f586113894174dfb31aa5bb1a ' ,
2016-02-11 12:10:32 -05:00
' info_dict ' : {
' id ' : ' 2658915080 ' ,
2016-05-20 01:53:14 -04:00
' ext ' : ' mp4 ' ,
2016-02-11 12:10:32 -05:00
' title ' : ' Fly like an eagle! ' ,
' description ' : ' Eagle equipped with a mini camera flies from the world \' s tallest tower ' ,
2016-05-20 01:53:14 -04:00
' upload_date ' : ' 20150315 ' ,
' timestamp ' : 1426443984 ,
' uploader ' : ' CBCC-NEW ' ,
2016-02-11 12:10:32 -05:00
} ,
} ] ,
2016-07-15 12:02:26 -04:00
' skip ' : ' Geo-restricted to Canada ' ,
2017-01-13 20:30:00 -05:00
} , {
# multiple CBC.APP.Caffeine.initInstance(...)
' url ' : ' http://www.cbc.ca/news/canada/calgary/dog-indoor-exercise-winter-1.3928238 ' ,
' info_dict ' : {
' title ' : ' Keep Rover active during the deep freeze with doggie pushups and other fun indoor tasks ' ,
' id ' : ' dog-indoor-exercise-winter-1.3928238 ' ,
2017-04-27 12:07:07 -04:00
' description ' : ' md5:c18552e41726ee95bd75210d1ca9194c ' ,
2017-01-13 20:30:00 -05:00
} ,
' playlist_mincount ' : 6 ,
2016-02-11 12:10:32 -05:00
} ]
@classmethod
def suitable ( cls , url ) :
return False if CBCPlayerIE . suitable ( url ) else super ( CBCIE , cls ) . suitable ( url )
2017-01-13 20:30:00 -05:00
def _extract_player_init ( self , player_init , display_id ) :
player_info = self . _parse_json ( player_init , display_id , js_to_json )
media_id = player_info . get ( ' mediaId ' )
if not media_id :
clip_id = player_info [ ' clipId ' ]
feed = self . _download_json (
' http://tpfeed.cbc.ca/f/ExhSPC/vms_5akSXx4Ng_Zn?byCustomValue= { :mpsReleases} { %s } ' % clip_id ,
clip_id , fatal = False )
if feed :
media_id = try_get ( feed , lambda x : x [ ' entries ' ] [ 0 ] [ ' guid ' ] , compat_str )
if not media_id :
media_id = self . _download_json (
' http://feed.theplatform.com/f/h9dtGB/punlNGjMlc1F?fields=id&byContent=byReleases % 3DbyId % 253D ' + clip_id ,
clip_id ) [ ' entries ' ] [ 0 ] [ ' id ' ] . split ( ' / ' ) [ - 1 ]
return self . url_result ( ' cbcplayer: %s ' % media_id , ' CBCPlayer ' , media_id )
2016-02-11 12:10:32 -05:00
def _real_extract ( self , url ) :
display_id = self . _match_id ( url )
webpage = self . _download_webpage ( url , display_id )
2018-05-26 09:05:54 -04:00
title = self . _og_search_title ( webpage , default = None ) or self . _html_search_meta (
' twitter:title ' , webpage , ' title ' , default = None ) or self . _html_search_regex (
r ' <title>([^<]+)</title> ' , webpage , ' title ' , fatal = False )
2017-01-13 20:30:00 -05:00
entries = [
self . _extract_player_init ( player_init , display_id )
for player_init in re . findall ( r ' CBC \ .APP \ .Caffeine \ .initInstance \ (( { .+?}) \ ); ' , webpage ) ]
2018-06-01 13:35:07 -04:00
media_ids = [ ]
for media_id_re in (
r ' <iframe[^>]+src= " [^ " ]+?mediaId=( \ d+) " ' ,
r ' <div[^>]+ \ bid=[ " \' ]player-( \ d+) ' ,
r ' guid[ " \' ] \ s*: \ s*[ " \' ]( \ d+) ' ) :
media_ids . extend ( re . findall ( media_id_re , webpage ) )
2017-01-13 20:30:00 -05:00
entries . extend ( [
self . url_result ( ' cbcplayer: %s ' % media_id , ' CBCPlayer ' , media_id )
2018-06-01 13:35:07 -04:00
for media_id in orderedSet ( media_ids ) ] )
2017-01-13 20:30:00 -05:00
return self . playlist_result (
2018-05-26 09:05:54 -04:00
entries , display_id , strip_or_none ( title ) ,
2017-01-13 20:30:00 -05:00
self . _og_search_description ( webpage ) )
2016-02-11 12:10:32 -05:00
class CBCPlayerIE ( InfoExtractor ) :
2016-08-25 03:49:15 -04:00
IE_NAME = ' cbc.ca:player '
2016-02-11 12:10:32 -05:00
_VALID_URL = r ' (?:cbcplayer:|https?://(?:www \ .)?cbc \ .ca/(?:player/play/|i/caffeine/syndicate/ \ ?mediaId=))(?P<id> \ d+) '
2016-05-20 07:04:50 -04:00
_TESTS = [ {
2016-02-11 12:10:32 -05:00
' url ' : ' http://www.cbc.ca/player/play/2683190193 ' ,
2016-05-20 11:20:05 -04:00
' md5 ' : ' 64d25f841ddf4ddb28a235338af32e2c ' ,
2016-02-11 12:10:32 -05:00
' info_dict ' : {
' id ' : ' 2683190193 ' ,
2016-05-20 01:53:14 -04:00
' ext ' : ' mp4 ' ,
2016-02-11 12:10:32 -05:00
' title ' : ' Gerry Runs a Sweat Shop ' ,
' description ' : ' md5:b457e1c01e8ff408d9d801c1c2cd29b0 ' ,
2016-05-20 01:53:14 -04:00
' timestamp ' : 1455071400 ,
2016-02-11 12:10:32 -05:00
' upload_date ' : ' 20160210 ' ,
2016-05-20 01:53:14 -04:00
' uploader ' : ' CBCC-NEW ' ,
2016-02-11 12:10:32 -05:00
} ,
2016-07-15 12:02:26 -04:00
' skip ' : ' Geo-restricted to Canada ' ,
2016-05-20 07:04:50 -04:00
} , {
# Redirected from http://www.cbc.ca/player/AudioMobile/All%20in%20a%20Weekend%20Montreal/ID/2657632011/
' url ' : ' http://www.cbc.ca/player/play/2657631896 ' ,
' md5 ' : ' e5e708c34ae6fca156aafe17c43e8b75 ' ,
' info_dict ' : {
' id ' : ' 2657631896 ' ,
' ext ' : ' mp3 ' ,
' title ' : ' CBC Montreal is organizing its first ever community hackathon! ' ,
' 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. ' ,
' timestamp ' : 1425704400 ,
' upload_date ' : ' 20150307 ' ,
' uploader ' : ' CBCC-NEW ' ,
} ,
2016-05-20 11:20:05 -04:00
} , {
' url ' : ' http://www.cbc.ca/player/play/2164402062 ' ,
2017-04-27 12:07:07 -04:00
' md5 ' : ' 33fcd8f6719b9dd60a5e73adcb83b9f6 ' ,
2016-05-20 11:20:05 -04:00
' info_dict ' : {
' id ' : ' 2164402062 ' ,
2017-04-27 12:07:07 -04:00
' ext ' : ' mp4 ' ,
2016-05-20 11:20:05 -04:00
' title ' : ' Cancer survivor four times over ' ,
' description ' : ' Tim Mayer has beaten three different forms of cancer four times in five years. ' ,
' timestamp ' : 1320410746 ,
' upload_date ' : ' 20111104 ' ,
' uploader ' : ' CBCC-NEW ' ,
} ,
2016-05-20 07:04:50 -04:00
} ]
2016-02-11 12:10:32 -05:00
def _real_extract ( self , url ) :
video_id = self . _match_id ( url )
2016-05-20 01:53:14 -04:00
return {
' _type ' : ' url_transparent ' ,
' ie_key ' : ' ThePlatform ' ,
' url ' : smuggle_url (
2016-05-20 11:20:05 -04:00
' http://link.theplatform.com/s/ExhSPC/media/guid/2655402169/ %s ?mbr=true&formats=MPEG4,FLV,MP3 ' % video_id , {
2016-05-20 01:53:14 -04:00
' force_smil_url ' : True
} ) ,
' id ' : video_id ,
}
2016-08-25 03:49:15 -04:00
2021-09-19 18:13:26 -04:00
class CBCGemIE ( InfoExtractor ) :
IE_NAME = ' gem.cbc.ca '
_VALID_URL = r ' https?://gem \ .cbc \ .ca/media/(?P<id>[0-9a-z-]+/s[0-9]+[a-z][0-9]+) '
_TESTS = [ {
2017-08-23 11:45:45 -04:00
# geo-restricted to Canada, bypassable
2021-09-19 18:13:26 -04:00
# This is a normal, public, TV show video
' url ' : ' https://gem.cbc.ca/media/schitts-creek/s06e01 ' ,
' md5 ' : ' 93dbb31c74a8e45b378cf13bd3f6f11e ' ,
' info_dict ' : {
' id ' : ' schitts-creek/s06e01 ' ,
' ext ' : ' mp4 ' ,
' title ' : ' Smoke Signals ' ,
' description ' : ' md5:929868d20021c924020641769eb3e7f1 ' ,
' thumbnail ' : ' https://images.radio-canada.ca/v1/synps-cbc/episode/perso/cbc_schitts_creek_season_06e01_thumbnail_v01.jpg?im=Resize=(Size) ' ,
' duration ' : 1314 ,
' categories ' : [ ' comedy ' ] ,
' series ' : ' Schitt \' s Creek ' ,
' season ' : ' Season 6 ' ,
' season_number ' : 6 ,
' episode ' : ' Smoke Signals ' ,
' episode_number ' : 1 ,
' episode_id ' : ' schitts-creek/s06e01 ' ,
} ,
' params ' : { ' format ' : ' bv ' } ,
' skip ' : ' Geo-restricted to Canada ' ,
} , {
# geo-restricted to Canada, bypassable
# This video requires an account in the browser, but works fine in yt-dlp
' url ' : ' https://gem.cbc.ca/media/schitts-creek/s01e01 ' ,
' md5 ' : ' 297a9600f554f2258aed01514226a697 ' ,
' info_dict ' : {
' id ' : ' schitts-creek/s01e01 ' ,
' ext ' : ' mp4 ' ,
' title ' : ' The Cup Runneth Over ' ,
' description ' : ' md5:9bca14ea49ab808097530eb05a29e797 ' ,
' thumbnail ' : ' https://images.radio-canada.ca/v1/synps-cbc/episode/perso/cbc_schitts_creek_season_01e01_thumbnail_v01.jpg?im=Resize=(Size) ' ,
' series ' : ' Schitt \' s Creek ' ,
' season_number ' : 1 ,
' season ' : ' Season 1 ' ,
' episode_number ' : 1 ,
' episode ' : ' The Cup Runneth Over ' ,
' episode_id ' : ' schitts-creek/s01e01 ' ,
' duration ' : 1309 ,
' categories ' : [ ' comedy ' ] ,
} ,
' params ' : { ' format ' : ' bv ' } ,
' skip ' : ' Geo-restricted to Canada ' ,
} ]
_API_BASE = ' https://services.radio-canada.ca/ott/cbc-api/v2/assets/ '
2016-08-25 03:49:15 -04:00
def _real_extract ( self , url ) :
video_id = self . _match_id ( url )
2021-09-19 18:13:26 -04:00
video_info = self . _download_json ( self . _API_BASE + video_id , video_id )
last_error = None
attempt = - 1
retries = self . get_param ( ' extractor_retries ' , 15 )
while attempt < retries :
attempt + = 1
if last_error :
self . report_warning ( ' %s . Retrying ... ' % last_error )
m3u8_info = self . _download_json (
video_info [ ' playSession ' ] [ ' url ' ] , video_id ,
note = ' Downloading JSON metadata %s ' % f ' (attempt { attempt } ) ' )
m3u8_url = m3u8_info . get ( ' url ' )
if m3u8_url :
break
elif m3u8_info . get ( ' errorCode ' ) == 1 :
self . raise_geo_restricted ( countries = [ ' CA ' ] )
else :
last_error = f ' { self . IE_NAME } said: { m3u8_info . get ( " errorCode " ) } - { m3u8_info . get ( " message " ) } '
# 35 means media unavailable, but retries work
if m3u8_info . get ( ' errorCode ' ) != 35 or attempt > = retries :
raise ExtractorError ( last_error )
formats = self . _extract_m3u8_formats ( m3u8_url , video_id , m3u8_id = ' hls ' )
self . _remove_duplicate_formats ( formats )
for i , format in enumerate ( formats ) :
if format . get ( ' vcodec ' ) == ' none ' :
if format . get ( ' ext ' ) is None :
format [ ' ext ' ] = ' m4a '
if format . get ( ' acodec ' ) is None :
format [ ' acodec ' ] = ' mp4a.40.2 '
# Put described audio at the beginning of the list, so that it
# isn't chosen by default, as most people won't want it.
if ' descriptive ' in format [ ' format_id ' ] . lower ( ) :
format [ ' preference ' ] = - 2
2016-08-25 03:49:15 -04:00
self . _sort_formats ( formats )
2021-09-19 18:13:26 -04:00
return {
2016-08-25 03:49:15 -04:00
' id ' : video_id ,
2021-09-19 18:13:26 -04:00
' title ' : video_info [ ' title ' ] ,
' description ' : video_info . get ( ' description ' ) ,
' thumbnail ' : video_info . get ( ' image ' ) ,
' series ' : video_info . get ( ' series ' ) ,
' season_number ' : video_info . get ( ' season ' ) ,
' season ' : f ' Season { video_info . get ( " season " ) } ' ,
' episode_number ' : video_info . get ( ' episode ' ) ,
' episode ' : video_info . get ( ' title ' ) ,
' episode_id ' : video_id ,
' duration ' : video_info . get ( ' duration ' ) ,
' categories ' : [ video_info . get ( ' category ' ) ] ,
2016-08-25 03:49:15 -04:00
' formats ' : formats ,
2021-09-19 18:13:26 -04:00
' release_timestamp ' : video_info . get ( ' airDate ' ) ,
' timestamp ' : video_info . get ( ' availableDate ' ) ,
2016-08-25 03:49:15 -04:00
}
2021-09-19 18:13:26 -04:00
class CBCGemPlaylistIE ( InfoExtractor ) :
IE_NAME = ' gem.cbc.ca:playlist '
_VALID_URL = r ' https?://gem \ .cbc \ .ca/media/(?P<id>(?P<show>[0-9a-z-]+)/s(?P<season>[0-9]+))/?(?:[?#]|$) '
2016-08-25 03:49:15 -04:00
_TESTS = [ {
2017-08-23 11:45:45 -04:00
# geo-restricted to Canada, bypassable
2021-09-19 18:13:26 -04:00
# TV show playlist, all public videos
' url ' : ' https://gem.cbc.ca/media/schitts-creek/s06 ' ,
' playlist_count ' : 16 ,
2016-08-25 03:49:15 -04:00
' info_dict ' : {
2021-09-19 18:13:26 -04:00
' id ' : ' schitts-creek/s06 ' ,
' title ' : ' Season 6 ' ,
' description ' : ' md5:6a92104a56cbeb5818cc47884d4326a2 ' ,
2016-08-25 03:49:15 -04:00
} ,
2021-09-19 18:13:26 -04:00
' skip ' : ' Geo-restricted to Canada ' ,
2016-08-25 03:49:15 -04:00
} ]
2021-09-19 18:13:26 -04:00
_API_BASE = ' https://services.radio-canada.ca/ott/cbc-api/v2/shows/ '
2016-08-25 03:49:15 -04:00
def _real_extract ( self , url ) :
2021-09-19 18:13:26 -04:00
match = self . _match_valid_url ( url )
season_id = match . group ( ' id ' )
show = match . group ( ' show ' )
show_info = self . _download_json ( self . _API_BASE + show , season_id )
season = int ( match . group ( ' season ' ) )
season_info = try_get ( show_info , lambda x : x [ ' seasons ' ] [ season - 1 ] )
if season_info is None :
raise ExtractorError ( f ' Couldn \' t find season { season } of { show } ' )
episodes = [ ]
for episode in season_info [ ' assets ' ] :
episodes . append ( {
' _type ' : ' url_transparent ' ,
' ie_key ' : ' CBCGem ' ,
' url ' : ' https://gem.cbc.ca/media/ ' + episode [ ' id ' ] ,
' id ' : episode [ ' id ' ] ,
' title ' : episode . get ( ' title ' ) ,
' description ' : episode . get ( ' description ' ) ,
' thumbnail ' : episode . get ( ' image ' ) ,
' series ' : episode . get ( ' series ' ) ,
' season_number ' : episode . get ( ' season ' ) ,
' season ' : season_info [ ' title ' ] ,
' season_id ' : season_info . get ( ' id ' ) ,
' episode_number ' : episode . get ( ' episode ' ) ,
' episode ' : episode . get ( ' title ' ) ,
' episode_id ' : episode [ ' id ' ] ,
' duration ' : episode . get ( ' duration ' ) ,
' categories ' : [ episode . get ( ' category ' ) ] ,
} )
2018-02-19 03:02:23 -05:00
2021-09-19 18:13:26 -04:00
thumbnail = None
tn_uri = season_info . get ( ' image ' )
# the-national was observed to use a "data:image/png;base64"
# URI for their 'image' value. The image was 1x1, and is
# probably just a placeholder, so it is ignored.
if tn_uri is not None and not tn_uri . startswith ( ' data: ' ) :
thumbnail = tn_uri
2018-02-19 03:02:23 -05:00
2021-09-19 18:13:26 -04:00
return {
' _type ' : ' playlist ' ,
' entries ' : episodes ,
' id ' : season_id ,
' title ' : season_info [ ' title ' ] ,
' description ' : season_info . get ( ' description ' ) ,
' thumbnail ' : thumbnail ,
' series ' : show_info . get ( ' title ' ) ,
' season_number ' : season_info . get ( ' season ' ) ,
' season ' : season_info [ ' title ' ] ,
}
class CBCGemLiveIE ( InfoExtractor ) :
IE_NAME = ' gem.cbc.ca:live '
_VALID_URL = r ' https?://gem \ .cbc \ .ca/live/(?P<id>[0-9] {12} ) '
_TEST = {
' url ' : ' https://gem.cbc.ca/live/920604739687 ' ,
' info_dict ' : {
' title ' : ' Ottawa ' ,
' description ' : ' The live TV channel and local programming from Ottawa ' ,
' thumbnail ' : ' https://thumbnails.cbc.ca/maven_legacy/thumbnails/CBC_OTT_VMS/Live_Channel_Static_Images/Ottawa_2880x1620.jpg ' ,
' is_live ' : True ,
' id ' : ' AyqZwxRqh8EH ' ,
' ext ' : ' mp4 ' ,
' timestamp ' : 1492106160 ,
' upload_date ' : ' 20170413 ' ,
' uploader ' : ' CBCC-NEW ' ,
} ,
' skip ' : ' Live might have ended ' ,
}
# It's unclear where the chars at the end come from, but they appear to be
# constant. Might need updating in the future.
_API = ' https://tpfeed.cbc.ca/f/ExhSPC/t_t3UKJR6MAT '
2018-02-19 03:02:23 -05:00
def _real_extract ( self , url ) :
2021-09-19 18:13:26 -04:00
video_id = self . _match_id ( url )
live_info = self . _download_json ( self . _API , video_id ) [ ' entries ' ]
video_info = None
for stream in live_info :
if stream . get ( ' guid ' ) == video_id :
video_info = stream
if video_info is None :
raise ExtractorError (
' Couldn \' t find video metadata, maybe this livestream is now offline ' ,
expected = True )
2018-02-19 03:02:23 -05:00
return {
2021-09-19 18:13:26 -04:00
' _type ' : ' url_transparent ' ,
' ie_key ' : ' ThePlatform ' ,
' url ' : video_info [ ' content ' ] [ 0 ] [ ' url ' ] ,
2018-02-19 03:02:23 -05:00
' id ' : video_id ,
2021-09-19 18:13:26 -04:00
' title ' : video_info . get ( ' title ' ) ,
' description ' : video_info . get ( ' description ' ) ,
' tags ' : try_get ( video_info , lambda x : x [ ' keywords ' ] . split ( ' , ' ) ) ,
' thumbnail ' : video_info . get ( ' cbc$staticImage ' ) ,
' is_live ' : True ,
2018-02-19 03:02:23 -05:00
}