mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-03 23:25:06 +00:00
[tva] fix extraction(fixes #14328)
This commit is contained in:
parent
4fe4bda287
commit
5fe75f976f
1 changed files with 23 additions and 25 deletions
|
@ -3,52 +3,50 @@
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
int_or_none,
|
float_or_none,
|
||||||
parse_iso8601,
|
|
||||||
smuggle_url,
|
smuggle_url,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class TVAIE(InfoExtractor):
|
class TVAIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://videos\.tva\.ca/episode/(?P<id>\d+)'
|
_VALID_URL = r'https?://videos\.tva\.ca/details/_(?P<id>\d+)'
|
||||||
_TEST = {
|
_TEST = {
|
||||||
'url': 'http://videos.tva.ca/episode/85538',
|
'url': 'https://videos.tva.ca/details/_5596811470001',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '85538',
|
'id': '5596811470001',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'Épisode du 25 janvier 2017',
|
'title': 'Un extrait de l\'épisode du dimanche 8 octobre 2017 !',
|
||||||
'description': 'md5:e9e7fb5532ab37984d2dc87229cadf98',
|
'uploader_id': '5481942443001',
|
||||||
'upload_date': '20170126',
|
'upload_date': '20171003',
|
||||||
'timestamp': 1485442329,
|
'timestamp': 1507064617,
|
||||||
},
|
},
|
||||||
'params': {
|
'params': {
|
||||||
# m3u8 download
|
# m3u8 download
|
||||||
'skip_download': True,
|
'skip_download': True,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/5481942443001/default_default/index.html?videoId=%s'
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
video_data = self._download_json(
|
video_data = self._download_json(
|
||||||
"https://d18jmrhziuoi7p.cloudfront.net/isl/api/v1/dataservice/Items('%s')" % video_id,
|
'https://videos.tva.ca/proxy/item/_' + video_id, video_id, headers={
|
||||||
video_id, query={
|
'Accept': 'application/json',
|
||||||
'$expand': 'Metadata,CustomId',
|
|
||||||
'$select': 'Metadata,Id,Title,ShortDescription,LongDescription,CreatedDate,CustomId,AverageUserRating,Categories,ShowName',
|
|
||||||
'$format': 'json',
|
|
||||||
})
|
})
|
||||||
metadata = video_data.get('Metadata', {})
|
|
||||||
|
def get_attribute(key):
|
||||||
|
for attribute in video_data.get('attributes', []):
|
||||||
|
if attribute.get('key') == key:
|
||||||
|
return attribute.get('value')
|
||||||
|
return None
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'_type': 'url_transparent',
|
'_type': 'url_transparent',
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': video_data['Title'],
|
'title': get_attribute('title'),
|
||||||
'url': smuggle_url('ooyala:' + video_data['CustomId'], {'supportedformats': 'm3u8,hds'}),
|
'url': smuggle_url(self.BRIGHTCOVE_URL_TEMPLATE % video_id, {'geo_countries': ['CA']}),
|
||||||
'description': video_data.get('LongDescription') or video_data.get('ShortDescription'),
|
'description': get_attribute('description'),
|
||||||
'series': video_data.get('ShowName'),
|
'thumbnail': get_attribute('image-background') or get_attribute('image-landscape'),
|
||||||
'episode': metadata.get('EpisodeTitle'),
|
'duration': float_or_none(get_attribute('video-duration'), 1000),
|
||||||
'episode_number': int_or_none(metadata.get('EpisodeNumber')),
|
'ie_key': 'BrightcoveNew',
|
||||||
'categories': video_data.get('Categories'),
|
|
||||||
'average_rating': video_data.get('AverageUserRating'),
|
|
||||||
'timestamp': parse_iso8601(video_data.get('CreatedDate')),
|
|
||||||
'ie_key': 'Ooyala',
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue