2024-05-08 22:10:06 +00:00
|
|
|
import functools
|
|
|
|
import re
|
|
|
|
|
2017-01-26 17:36:28 +00:00
|
|
|
from .common import InfoExtractor
|
2024-05-08 22:10:06 +00:00
|
|
|
from ..utils import float_or_none, int_or_none, smuggle_url, strip_or_none
|
|
|
|
from ..utils.traversal import traverse_obj
|
2017-01-26 17:36:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TVAIE(InfoExtractor):
|
2020-01-30 20:49:16 +00:00
|
|
|
_VALID_URL = r'https?://videos?\.tva\.ca/details/_(?P<id>\d+)'
|
|
|
|
_TESTS = [{
|
2017-10-11 14:14:51 +00:00
|
|
|
'url': 'https://videos.tva.ca/details/_5596811470001',
|
2017-01-26 17:36:28 +00:00
|
|
|
'info_dict': {
|
2017-10-11 14:14:51 +00:00
|
|
|
'id': '5596811470001',
|
2017-01-26 17:36:28 +00:00
|
|
|
'ext': 'mp4',
|
2017-10-11 14:14:51 +00:00
|
|
|
'title': 'Un extrait de l\'épisode du dimanche 8 octobre 2017 !',
|
|
|
|
'uploader_id': '5481942443001',
|
|
|
|
'upload_date': '20171003',
|
|
|
|
'timestamp': 1507064617,
|
2017-01-26 17:36:28 +00:00
|
|
|
},
|
|
|
|
'params': {
|
|
|
|
# m3u8 download
|
|
|
|
'skip_download': True,
|
2021-01-01 12:26:37 +00:00
|
|
|
},
|
|
|
|
'skip': 'HTTP Error 404: Not Found',
|
2020-01-30 20:49:16 +00:00
|
|
|
}, {
|
|
|
|
'url': 'https://video.tva.ca/details/_5596811470001',
|
|
|
|
'only_matching': True,
|
|
|
|
}]
|
2017-10-11 14:14:51 +00:00
|
|
|
BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/5481942443001/default_default/index.html?videoId=%s'
|
2017-01-26 17:36:28 +00:00
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
video_id = self._match_id(url)
|
|
|
|
|
|
|
|
return {
|
|
|
|
'_type': 'url_transparent',
|
|
|
|
'id': video_id,
|
2017-10-11 14:14:51 +00:00
|
|
|
'url': smuggle_url(self.BRIGHTCOVE_URL_TEMPLATE % video_id, {'geo_countries': ['CA']}),
|
|
|
|
'ie_key': 'BrightcoveNew',
|
2017-01-26 17:36:28 +00:00
|
|
|
}
|
2021-01-01 12:26:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
class QubIE(InfoExtractor):
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?qub\.ca/(?:[^/]+/)*[0-9a-z-]+-(?P<id>\d+)'
|
|
|
|
_TESTS = [{
|
|
|
|
'url': 'https://www.qub.ca/tvaplus/tva/alerte-amber/saison-1/episode-01-1000036619',
|
|
|
|
'md5': '949490fd0e7aee11d0543777611fbd53',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '6084352463001',
|
|
|
|
'ext': 'mp4',
|
2024-05-08 22:10:06 +00:00
|
|
|
'title': 'Ép 01. Mon dernier jour',
|
2021-01-01 12:26:37 +00:00
|
|
|
'uploader_id': '5481942443001',
|
|
|
|
'upload_date': '20190907',
|
|
|
|
'timestamp': 1567899756,
|
|
|
|
'description': 'md5:9c0d7fbb90939420c651fd977df90145',
|
2024-05-08 22:10:06 +00:00
|
|
|
'thumbnail': r're:https://.+\.jpg',
|
|
|
|
'episode': 'Ép 01. Mon dernier jour',
|
|
|
|
'episode_number': 1,
|
|
|
|
'tags': ['alerte amber', 'alerte amber saison 1', 'surdemande'],
|
|
|
|
'duration': 2625.963,
|
|
|
|
'season': 'Season 1',
|
|
|
|
'season_number': 1,
|
|
|
|
'series': 'Alerte Amber',
|
|
|
|
'channel': 'TVA',
|
2021-01-01 12:26:37 +00:00
|
|
|
},
|
|
|
|
}, {
|
|
|
|
'url': 'https://www.qub.ca/tele/video/lcn-ca-vous-regarde-rev-30s-ap369664-1009357943',
|
|
|
|
'only_matching': True,
|
|
|
|
}]
|
|
|
|
# reference_id also works with old account_id(5481942443001)
|
|
|
|
# BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/5813221784001/default_default/index.html?videoId=ref:%s'
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
entity_id = self._match_id(url)
|
2024-05-08 22:10:06 +00:00
|
|
|
webpage = self._download_webpage(url, entity_id)
|
|
|
|
entity = self._search_nextjs_data(webpage, entity_id)['props']['initialProps']['pageProps']['fallbackData']
|
2021-01-01 12:26:37 +00:00
|
|
|
video_id = entity['videoId']
|
|
|
|
episode = strip_or_none(entity.get('name'))
|
|
|
|
|
|
|
|
return {
|
|
|
|
'_type': 'url_transparent',
|
2024-05-08 22:10:06 +00:00
|
|
|
'url': f'https://videos.tva.ca/details/_{video_id}',
|
|
|
|
'ie_key': TVAIE.ie_key(),
|
2021-01-01 12:26:37 +00:00
|
|
|
'id': video_id,
|
|
|
|
'title': episode,
|
|
|
|
'episode': episode,
|
2024-05-08 22:10:06 +00:00
|
|
|
**traverse_obj(entity, {
|
|
|
|
'description': ('longDescription', {str}),
|
|
|
|
'duration': ('durationMillis', {functools.partial(float_or_none, scale=1000)}),
|
|
|
|
'channel': ('knownEntities', 'channel', 'name', {str}),
|
|
|
|
'series': ('knownEntities', 'videoShow', 'name', {str}),
|
|
|
|
'season_number': ('slug', {lambda x: re.search(r'/s(?:ai|ea)son-(\d+)/', x)}, 1, {int_or_none}),
|
|
|
|
'episode_number': ('episodeNumber', {int_or_none}),
|
|
|
|
}),
|
2021-01-01 12:26:37 +00:00
|
|
|
}
|