mirror of https://github.com/yt-dlp/yt-dlp.git
Fixes tva.py extractor
This commit is contained in:
parent
ef8fb7f029
commit
fac0045470
|
@ -1,9 +1,16 @@
|
||||||
|
# coding: utf-8
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
|
from ..compat import compat_str
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
float_or_none,
|
float_or_none,
|
||||||
|
get_element_by_id,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
smuggle_url,
|
smuggle_url,
|
||||||
|
str_to_int,
|
||||||
strip_or_none,
|
strip_or_none,
|
||||||
|
try_get,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,37 +56,67 @@ class QubIE(InfoExtractor):
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '6084352463001',
|
'id': '6084352463001',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'Épisode 01',
|
'title': 'Ép 01. Mon dernier jour',
|
||||||
'uploader_id': '5481942443001',
|
'uploader_id': '5481942443001',
|
||||||
'upload_date': '20190907',
|
'upload_date': '20190907',
|
||||||
'timestamp': 1567899756,
|
'timestamp': 1567899756,
|
||||||
'description': 'md5:9c0d7fbb90939420c651fd977df90145',
|
'description': 'md5:9c0d7fbb90939420c651fd977df90145',
|
||||||
|
'age_limit': 13,
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
'url': 'https://www.qub.ca/tvaplus/tva/indefendable/saison-1/episode-2-apte-a-subir-son-proces-1080300766',
|
||||||
|
'md5': 'ba7e0da53f472d39230418a9d980dc9f',
|
||||||
|
'info_dict': {
|
||||||
|
'id': '6312064712112',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'description': 'md5:9fd8701b50199e52fe9a5a43d20862e9',
|
||||||
|
'title': 'Ép 02. Apte à subir son procès?',
|
||||||
|
'timestamp': 1662681334,
|
||||||
|
'upload_date': '20220908',
|
||||||
|
'uploader_id': '5481942443001',
|
||||||
|
'age_limit': 8,
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://www.qub.ca/tele/video/lcn-ca-vous-regarde-rev-30s-ap369664-1009357943',
|
'url': 'https://www.qub.ca/tele/video/lcn-ca-vous-regarde-rev-30s-ap369664-1009357943',
|
||||||
'only_matching': True,
|
'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'
|
@staticmethod
|
||||||
|
def _parse_rating(rating):
|
||||||
|
age = str_to_int(rating)
|
||||||
|
if age is not None:
|
||||||
|
return age
|
||||||
|
return {
|
||||||
|
# CBSC
|
||||||
|
'Exempt': None,
|
||||||
|
'C': 0,
|
||||||
|
'C8': 8,
|
||||||
|
'G': 0,
|
||||||
|
'PG': 10,
|
||||||
|
# Régie du cinéma
|
||||||
|
'G-Dec': 8, # "déconseillé"
|
||||||
|
}.get(rating)
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
entity_id = self._match_id(url)
|
entity_id = self._match_id(url)
|
||||||
entity = self._download_json(
|
webpage = self._download_webpage(url, entity_id)
|
||||||
'https://www.qub.ca/proxy/pfu/content-delivery-service/v1/entities',
|
next_data = get_element_by_id('__NEXT_DATA__', webpage) or '{}'
|
||||||
entity_id, query={'id': entity_id})
|
entity = self._parse_json(next_data, entity_id)['props']['initialProps']['pageProps']['fallbackData']
|
||||||
video_id = entity['videoId']
|
video_id = entity['videoId']
|
||||||
episode = strip_or_none(entity.get('name'))
|
episode = strip_or_none(entity.get('name')) or None
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'_type': 'url_transparent',
|
'_type': 'url_transparent',
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': episode,
|
'title': episode or self._generic_title(url),
|
||||||
# 'url': self.BRIGHTCOVE_URL_TEMPLATE % entity['referenceId'],
|
|
||||||
'url': 'https://videos.tva.ca/details/_' + video_id,
|
'url': 'https://videos.tva.ca/details/_' + video_id,
|
||||||
'description': entity.get('longDescription'),
|
'description': entity.get('longDescription'),
|
||||||
'duration': float_or_none(entity.get('durationMillis'), 1000),
|
'duration': float_or_none(entity.get('durationMillis'), 1000),
|
||||||
'episode': episode,
|
'episode': episode,
|
||||||
'episode_number': int_or_none(entity.get('episodeNumber')),
|
'episode_number': int_or_none(entity.get('episodeNumber')),
|
||||||
# 'ie_key': 'BrightcoveNew',
|
'channel': try_get(entity, lambda x: x['knownEntities']['channel']['name'], compat_str),
|
||||||
|
'series': try_get(entity, lambda x: x['knownEntities']['videoShow']['name'], compat_str),
|
||||||
|
'season_number': int_or_none(self._search_regex(r'/s(?:ai|ea)son-(\d+)/', entity.get('slug', ''), 'season', default=None)),
|
||||||
|
'age_limit': self._parse_rating(entity.get('parentalRating')),
|
||||||
'ie_key': TVAIE.ie_key(),
|
'ie_key': TVAIE.ie_key(),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue