2016-09-08 17:53:44 -04:00
|
|
|
|
from .common import InfoExtractor
|
2017-02-21 11:50:36 -05:00
|
|
|
|
from ..utils import (
|
|
|
|
|
int_or_none,
|
|
|
|
|
smuggle_url,
|
2017-03-08 06:25:04 -05:00
|
|
|
|
try_get,
|
2019-10-04 09:14:45 -04:00
|
|
|
|
unified_timestamp,
|
2017-02-21 11:50:36 -05:00
|
|
|
|
)
|
2016-09-08 17:53:44 -04:00
|
|
|
|
|
|
|
|
|
|
2018-02-25 04:54:12 -05:00
|
|
|
|
class TeleQuebecBaseIE(InfoExtractor):
|
2021-01-01 07:26:37 -05:00
|
|
|
|
BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/%s/%s_default/index.html?videoId=%s'
|
|
|
|
|
|
2018-02-25 04:54:12 -05:00
|
|
|
|
@staticmethod
|
2021-01-01 07:26:37 -05:00
|
|
|
|
def _brightcove_result(brightcove_id, player_id, account_id='6150020952001'):
|
2018-02-25 04:54:12 -05:00
|
|
|
|
return {
|
|
|
|
|
'_type': 'url_transparent',
|
2021-01-01 07:26:37 -05:00
|
|
|
|
'url': smuggle_url(TeleQuebecBaseIE.BRIGHTCOVE_URL_TEMPLATE % (account_id, player_id, brightcove_id), {'geo_countries': ['CA']}),
|
|
|
|
|
'ie_key': 'BrightcoveNew',
|
2018-02-25 04:54:12 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TeleQuebecIE(TeleQuebecBaseIE):
|
2019-10-04 08:14:31 -04:00
|
|
|
|
_VALID_URL = r'''(?x)
|
|
|
|
|
https?://
|
|
|
|
|
(?:
|
|
|
|
|
zonevideo\.telequebec\.tv/media|
|
|
|
|
|
coucou\.telequebec\.tv/videos
|
|
|
|
|
)/(?P<id>\d+)
|
|
|
|
|
'''
|
2017-03-08 06:25:04 -05:00
|
|
|
|
_TESTS = [{
|
2018-02-25 04:54:12 -05:00
|
|
|
|
# available till 01.01.2023
|
|
|
|
|
'url': 'http://zonevideo.telequebec.tv/media/37578/un-petit-choc-et-puis-repart/un-chef-a-la-cabane',
|
2016-09-08 17:53:44 -04:00
|
|
|
|
'info_dict': {
|
2021-01-01 07:26:37 -05:00
|
|
|
|
'id': '6155972771001',
|
2016-09-08 17:53:44 -04:00
|
|
|
|
'ext': 'mp4',
|
2018-02-25 04:54:12 -05:00
|
|
|
|
'title': 'Un petit choc et puis repart!',
|
2021-01-01 07:26:37 -05:00
|
|
|
|
'description': 'md5:b04a7e6b3f74e32d7b294cffe8658374',
|
|
|
|
|
'timestamp': 1589262469,
|
|
|
|
|
'uploader_id': '6150020952001',
|
|
|
|
|
'upload_date': '20200512',
|
2018-02-25 04:54:12 -05:00
|
|
|
|
},
|
2021-01-01 07:26:37 -05:00
|
|
|
|
'add_ie': ['BrightcoveNew'],
|
2020-09-18 20:52:42 -04:00
|
|
|
|
}, {
|
|
|
|
|
'url': 'https://zonevideo.telequebec.tv/media/55267/le-soleil/passe-partout',
|
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': '6167180337001',
|
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
'title': 'Le soleil',
|
|
|
|
|
'description': 'md5:64289c922a8de2abbe99c354daffde02',
|
|
|
|
|
'uploader_id': '6150020952001',
|
|
|
|
|
'upload_date': '20200625',
|
|
|
|
|
'timestamp': 1593090307,
|
|
|
|
|
},
|
|
|
|
|
'add_ie': ['BrightcoveNew'],
|
2017-03-08 06:25:04 -05:00
|
|
|
|
}, {
|
|
|
|
|
# no description
|
|
|
|
|
'url': 'http://zonevideo.telequebec.tv/media/30261',
|
|
|
|
|
'only_matching': True,
|
2019-10-04 08:14:31 -04:00
|
|
|
|
}, {
|
|
|
|
|
'url': 'https://coucou.telequebec.tv/videos/41788/idee-de-genie/l-heure-du-bain',
|
|
|
|
|
'only_matching': True,
|
2017-03-08 06:25:04 -05:00
|
|
|
|
}]
|
2016-09-08 17:53:44 -04:00
|
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
|
media_id = self._match_id(url)
|
2021-01-01 07:26:37 -05:00
|
|
|
|
media = self._download_json(
|
|
|
|
|
'https://mnmedias.api.telequebec.tv/api/v3/media/' + media_id,
|
2016-09-08 17:53:44 -04:00
|
|
|
|
media_id)['media']
|
2021-01-01 07:26:37 -05:00
|
|
|
|
source_id = next(source_info['sourceId'] for source_info in media['streamInfos'] if source_info.get('source') == 'Brightcove')
|
|
|
|
|
info = self._brightcove_result(source_id, '22gPKdt7f')
|
|
|
|
|
product = media.get('product') or {}
|
|
|
|
|
season = product.get('season') or {}
|
2018-02-25 04:54:12 -05:00
|
|
|
|
info.update({
|
2024-06-11 19:09:58 -04:00
|
|
|
|
'description': try_get(media, lambda x: x['descriptions'][-1]['text'], str),
|
2021-01-01 07:26:37 -05:00
|
|
|
|
'series': try_get(season, lambda x: x['serie']['titre']),
|
|
|
|
|
'season': season.get('name'),
|
|
|
|
|
'season_number': int_or_none(season.get('seasonNo')),
|
|
|
|
|
'episode': product.get('titre'),
|
|
|
|
|
'episode_number': int_or_none(product.get('episodeNo')),
|
2018-02-25 04:54:12 -05:00
|
|
|
|
})
|
|
|
|
|
return info
|
|
|
|
|
|
|
|
|
|
|
2019-10-04 09:14:45 -04:00
|
|
|
|
class TeleQuebecSquatIE(InfoExtractor):
|
2024-02-01 13:38:42 -05:00
|
|
|
|
_VALID_URL = r'https?://squat\.telequebec\.tv/videos/(?P<id>\d+)'
|
2019-10-04 09:14:45 -04:00
|
|
|
|
_TESTS = [{
|
|
|
|
|
'url': 'https://squat.telequebec.tv/videos/9314',
|
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': 'd59ae78112d542e793d83cc9d3a5b530',
|
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
'title': 'Poupeflekta',
|
|
|
|
|
'description': 'md5:2f0718f8d2f8fece1646ee25fb7bce75',
|
|
|
|
|
'duration': 1351,
|
|
|
|
|
'timestamp': 1569057600,
|
|
|
|
|
'upload_date': '20190921',
|
|
|
|
|
'series': 'Miraculous : Les Aventures de Ladybug et Chat Noir',
|
|
|
|
|
'season': 'Saison 3',
|
|
|
|
|
'season_number': 3,
|
|
|
|
|
'episode_number': 57,
|
|
|
|
|
},
|
|
|
|
|
'params': {
|
|
|
|
|
'skip_download': True,
|
|
|
|
|
},
|
|
|
|
|
}]
|
|
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
|
video_id = self._match_id(url)
|
|
|
|
|
|
|
|
|
|
video = self._download_json(
|
2024-06-11 19:09:58 -04:00
|
|
|
|
f'https://squat.api.telequebec.tv/v1/videos/{video_id}',
|
2019-10-04 09:14:45 -04:00
|
|
|
|
video_id)
|
|
|
|
|
|
|
|
|
|
media_id = video['sourceId']
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
'_type': 'url_transparent',
|
2024-06-11 19:09:58 -04:00
|
|
|
|
'url': f'http://zonevideo.telequebec.tv/media/{media_id}',
|
2019-10-04 09:14:45 -04:00
|
|
|
|
'ie_key': TeleQuebecIE.ie_key(),
|
|
|
|
|
'id': media_id,
|
|
|
|
|
'title': video.get('titre'),
|
|
|
|
|
'description': video.get('description'),
|
|
|
|
|
'timestamp': unified_timestamp(video.get('datePublication')),
|
|
|
|
|
'series': video.get('container'),
|
|
|
|
|
'season': video.get('saison'),
|
|
|
|
|
'season_number': int_or_none(video.get('noSaison')),
|
|
|
|
|
'episode_number': int_or_none(video.get('episode')),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2021-01-01 07:26:37 -05:00
|
|
|
|
class TeleQuebecEmissionIE(InfoExtractor):
|
2018-02-25 05:05:39 -05:00
|
|
|
|
_VALID_URL = r'''(?x)
|
|
|
|
|
https?://
|
|
|
|
|
(?:
|
|
|
|
|
[^/]+\.telequebec\.tv/emissions/|
|
|
|
|
|
(?:www\.)?telequebec\.tv/
|
|
|
|
|
)
|
|
|
|
|
(?P<id>[^?#&]+)
|
|
|
|
|
'''
|
2018-02-25 04:54:12 -05:00
|
|
|
|
_TESTS = [{
|
|
|
|
|
'url': 'http://lindicemcsween.telequebec.tv/emissions/100430013/des-soins-esthetiques-a-377-d-interets-annuels-ca-vous-tente',
|
|
|
|
|
'info_dict': {
|
2021-01-01 07:26:37 -05:00
|
|
|
|
'id': '6154476028001',
|
2018-02-25 04:54:12 -05:00
|
|
|
|
'ext': 'mp4',
|
2021-01-01 07:26:37 -05:00
|
|
|
|
'title': 'Des soins esthétiques à 377 % d’intérêts annuels, ça vous tente?',
|
|
|
|
|
'description': 'md5:cb4d378e073fae6cce1f87c00f84ae9f',
|
|
|
|
|
'upload_date': '20200505',
|
|
|
|
|
'timestamp': 1588713424,
|
|
|
|
|
'uploader_id': '6150020952001',
|
2018-02-25 04:54:12 -05:00
|
|
|
|
},
|
|
|
|
|
}, {
|
|
|
|
|
'url': 'http://bancpublic.telequebec.tv/emissions/emission-49/31986/jeunes-meres-sous-pression',
|
|
|
|
|
'only_matching': True,
|
2018-02-25 05:05:39 -05:00
|
|
|
|
}, {
|
|
|
|
|
'url': 'http://www.telequebec.tv/masha-et-michka/epi059masha-et-michka-3-053-078',
|
|
|
|
|
'only_matching': True,
|
|
|
|
|
}, {
|
|
|
|
|
'url': 'http://www.telequebec.tv/documentaire/bebes-sur-mesure/',
|
|
|
|
|
'only_matching': True,
|
2018-02-25 04:54:12 -05:00
|
|
|
|
}]
|
|
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
|
display_id = self._match_id(url)
|
|
|
|
|
|
|
|
|
|
webpage = self._download_webpage(url, display_id)
|
|
|
|
|
|
|
|
|
|
media_id = self._search_regex(
|
2021-01-01 07:26:37 -05:00
|
|
|
|
r'mediaId\s*:\s*(?P<id>\d+)', webpage, 'media id')
|
2018-02-25 04:54:12 -05:00
|
|
|
|
|
2021-01-01 07:26:37 -05:00
|
|
|
|
return self.url_result(
|
|
|
|
|
'http://zonevideo.telequebec.tv/media/' + media_id,
|
|
|
|
|
TeleQuebecIE.ie_key())
|
2018-02-23 18:16:42 -05:00
|
|
|
|
|
|
|
|
|
|
2021-01-01 07:26:37 -05:00
|
|
|
|
class TeleQuebecLiveIE(TeleQuebecBaseIE):
|
2018-02-23 18:16:42 -05:00
|
|
|
|
_VALID_URL = r'https?://zonevideo\.telequebec\.tv/(?P<id>endirect)'
|
|
|
|
|
_TEST = {
|
|
|
|
|
'url': 'http://zonevideo.telequebec.tv/endirect/',
|
|
|
|
|
'info_dict': {
|
2021-01-01 07:26:37 -05:00
|
|
|
|
'id': '6159095684001',
|
2018-02-23 18:16:42 -05:00
|
|
|
|
'ext': 'mp4',
|
2021-01-01 07:26:37 -05:00
|
|
|
|
'title': 're:^Télé-Québec [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
|
2018-02-23 18:16:42 -05:00
|
|
|
|
'is_live': True,
|
2021-01-01 07:26:37 -05:00
|
|
|
|
'description': 'Canal principal de Télé-Québec',
|
|
|
|
|
'uploader_id': '6150020952001',
|
|
|
|
|
'timestamp': 1590439901,
|
|
|
|
|
'upload_date': '20200525',
|
2018-02-23 18:16:42 -05:00
|
|
|
|
},
|
|
|
|
|
'params': {
|
|
|
|
|
'skip_download': True,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2021-01-01 07:26:37 -05:00
|
|
|
|
return self._brightcove_result('6159095684001', 'skCsmi2Uw')
|
2018-02-23 18:16:42 -05:00
|
|
|
|
|
|
|
|
|
|
2021-01-01 07:26:37 -05:00
|
|
|
|
class TeleQuebecVideoIE(TeleQuebecBaseIE):
|
|
|
|
|
_VALID_URL = r'https?://video\.telequebec\.tv/player(?:-live)?/(?P<id>\d+)'
|
|
|
|
|
_TESTS = [{
|
|
|
|
|
'url': 'https://video.telequebec.tv/player/31110/stream',
|
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': '6202570652001',
|
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
'title': 'Le coût du véhicule le plus vendu au Canada / Tous les frais liés à la procréation assistée',
|
|
|
|
|
'description': 'md5:685a7e4c450ba777c60adb6e71e41526',
|
|
|
|
|
'upload_date': '20201019',
|
|
|
|
|
'timestamp': 1603115930,
|
|
|
|
|
'uploader_id': '6101674910001',
|
|
|
|
|
},
|
|
|
|
|
}, {
|
|
|
|
|
'url': 'https://video.telequebec.tv/player-live/28527',
|
|
|
|
|
'only_matching': True,
|
|
|
|
|
}]
|
|
|
|
|
|
|
|
|
|
def _call_api(self, path, video_id):
|
|
|
|
|
return self._download_json(
|
|
|
|
|
'http://beacon.playback.api.brightcove.com/telequebec/api/assets/' + path,
|
|
|
|
|
video_id, query={'device_layout': 'web', 'device_type': 'web'})['data']
|
|
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
|
asset_id = self._match_id(url)
|
|
|
|
|
asset = self._call_api(asset_id, asset_id)['asset']
|
|
|
|
|
stream = self._call_api(
|
|
|
|
|
asset_id + '/streams/' + asset['streams'][0]['id'], asset_id)['stream']
|
|
|
|
|
stream_url = stream['url']
|
|
|
|
|
account_id = try_get(
|
|
|
|
|
stream, lambda x: x['video_provider_details']['account_id']) or '6101674910001'
|
|
|
|
|
info = self._brightcove_result(stream_url, 'default', account_id)
|
|
|
|
|
info.update({
|
|
|
|
|
'description': asset.get('long_description') or asset.get('short_description'),
|
|
|
|
|
'series': asset.get('series_original_name'),
|
|
|
|
|
'season_number': int_or_none(asset.get('season_number')),
|
|
|
|
|
'episode': asset.get('original_name'),
|
|
|
|
|
'episode_number': int_or_none(asset.get('episode_number')),
|
|
|
|
|
})
|
|
|
|
|
return info
|