mirror of
https://github.com/yt-dlp/yt-dlp
synced 2024-11-16 07:48:01 +01:00
[ie/TV5Monde] Fix extractor (#9143)
Closes #9118 Authored by: alard, seproDev Co-authored-by: sepro <4618135+seproDev@users.noreply.github.com>
This commit is contained in:
parent
800a43983e
commit
6db96268c5
1 changed files with 68 additions and 81 deletions
|
@ -2,85 +2,88 @@ import urllib.parse
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
|
clean_html,
|
||||||
determine_ext,
|
determine_ext,
|
||||||
extract_attributes,
|
extract_attributes,
|
||||||
|
get_element_by_class,
|
||||||
|
get_element_html_by_class,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
parse_duration,
|
|
||||||
traverse_obj,
|
|
||||||
try_get,
|
|
||||||
url_or_none,
|
url_or_none,
|
||||||
)
|
)
|
||||||
|
from ..utils.traversal import traverse_obj
|
||||||
|
|
||||||
|
|
||||||
class TV5MondePlusIE(InfoExtractor):
|
class TV5MondePlusIE(InfoExtractor):
|
||||||
IE_DESC = 'TV5MONDE+'
|
IE_NAME = 'TV5MONDE'
|
||||||
_VALID_URL = r'https?://(?:www\.)?(?:tv5mondeplus|revoir\.tv5monde)\.com/toutes-les-videos/[^/]+/(?P<id>[^/?#]+)'
|
_VALID_URL = r'https?://(?:www\.)?tv5monde\.com/tv/video/(?P<id>[^/?#]+)'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
# movie
|
# documentary
|
||||||
'url': 'https://revoir.tv5monde.com/toutes-les-videos/cinema/les-novices',
|
'url': 'https://www.tv5monde.com/tv/video/65931-baudouin-l-heritage-d-un-roi-baudouin-l-heritage-d-un-roi',
|
||||||
'md5': 'c86f60bf8b75436455b1b205f9745955',
|
'md5': 'd2a708902d3df230a357c99701aece05',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': 'ZX0ipMyFQq_6D4BA7b',
|
'id': '3FPa7JMu21_6D4BA7b',
|
||||||
'display_id': 'les-novices',
|
'display_id': '65931-baudouin-l-heritage-d-un-roi-baudouin-l-heritage-d-un-roi',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'Les novices',
|
'title': "Baudouin, l'héritage d'un roi",
|
||||||
'description': 'md5:2e7c33ba3ad48dabfcc2a956b88bde2b',
|
'thumbnail': 'https://psi.tv5monde.com/upsilon-images/960x540/6f/baudouin-f49c6b0e.jpg',
|
||||||
'upload_date': '20230821',
|
'duration': 4842,
|
||||||
'thumbnail': 'https://revoir.tv5monde.com/uploads/media/video_thumbnail/0738/60/01e952b7ccf36b7c6007ec9131588954ab651de9.jpeg',
|
'upload_date': '20240130',
|
||||||
'duration': 5177,
|
'timestamp': 1706641242,
|
||||||
'episode': 'Les novices',
|
'episode': "BAUDOUIN, L'HERITAGE D'UN ROI",
|
||||||
|
'description': 'md5:78125c74a5cac06d7743a2d09126edad',
|
||||||
|
'series': "Baudouin, l'héritage d'un roi",
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
# series episode
|
# series episode
|
||||||
'url': 'https://revoir.tv5monde.com/toutes-les-videos/series-fictions/opj-les-dents-de-la-terre-2',
|
'url': 'https://www.tv5monde.com/tv/video/52952-toute-la-vie-mardi-23-mars-2021',
|
||||||
|
'md5': 'f5e09637cadd55639c05874e22eb56bf',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': 'wJ0eeEPozr_6D4BA7b',
|
'id': 'obRRZ8m6g9_6D4BA7b',
|
||||||
'display_id': 'opj-les-dents-de-la-terre-2',
|
'display_id': '52952-toute-la-vie-mardi-23-mars-2021',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': "OPJ - Les dents de la Terre (2)",
|
'title': 'Toute la vie',
|
||||||
'description': 'md5:288f87fd68d993f814e66e60e5302d9d',
|
'description': 'md5:a824a2e1dfd94cf45fa379a1fb43ce65',
|
||||||
'upload_date': '20230823',
|
'thumbnail': 'https://psi.tv5monde.com/media/image/960px/5880553.jpg',
|
||||||
'series': 'OPJ',
|
'duration': 2526,
|
||||||
'episode': 'Les dents de la Terre (2)',
|
'upload_date': '20230721',
|
||||||
'duration': 2877,
|
'timestamp': 1689971646,
|
||||||
'thumbnail': 'https://dl-revoir.tv5monde.com/images/1a/5753448.jpg'
|
'series': 'Toute la vie',
|
||||||
|
'episode': 'Mardi 23 mars 2021',
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
# movie
|
# movie
|
||||||
'url': 'https://revoir.tv5monde.com/toutes-les-videos/cinema/ceux-qui-travaillent',
|
'url': 'https://www.tv5monde.com/tv/video/8771-ce-fleuve-qui-nous-charrie-ce-fleuve-qui-nous-charrie-p001-ce-fleuve-qui-nous-charrie',
|
||||||
'md5': '32fa0cde16a4480d1251502a66856d5f',
|
'md5': '87cefc34e10a6bf4f7823cccd7b36eb2',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': 'dc57a011-ec4b-4648-2a9a-4f03f8352ed3',
|
'id': 'DOcfvdLKXL_6D4BA7b',
|
||||||
'display_id': 'ceux-qui-travaillent',
|
'display_id': '8771-ce-fleuve-qui-nous-charrie-ce-fleuve-qui-nous-charrie-p001-ce-fleuve-qui-nous-charrie',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'Ceux qui travaillent',
|
'title': 'Ce fleuve qui nous charrie',
|
||||||
'description': 'md5:570e8bb688036ace873b2d50d24c026d',
|
'description': 'md5:62ba3f875343c7fc4082bdfbbc1be992',
|
||||||
'upload_date': '20210819',
|
'thumbnail': 'https://psi.tv5monde.com/media/image/960px/5476617.jpg',
|
||||||
|
'duration': 5300,
|
||||||
|
'upload_date': '20210822',
|
||||||
|
'timestamp': 1629594105,
|
||||||
|
'episode': 'CE FLEUVE QUI NOUS CHARRIE-P001-CE FLEUVE QUI NOUS CHARRIE',
|
||||||
|
'series': 'Ce fleuve qui nous charrie',
|
||||||
},
|
},
|
||||||
'skip': 'no longer available',
|
|
||||||
}, {
|
}, {
|
||||||
# series episode
|
# news
|
||||||
'url': 'https://revoir.tv5monde.com/toutes-les-videos/series-fictions/vestiaires-caro-actrice',
|
'url': 'https://www.tv5monde.com/tv/video/70402-tv5monde-le-journal-edition-du-08-05-24-11h',
|
||||||
|
'md5': 'c62977d6d10754a2ecebba70ad370479',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '9e9d599e-23af-6915-843e-ecbf62e97925',
|
'id': 'LgQFrOCNsc_6D4BA7b',
|
||||||
'display_id': 'vestiaires-caro-actrice',
|
'display_id': '70402-tv5monde-le-journal-edition-du-08-05-24-11h',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': "Vestiaires - Caro actrice",
|
'title': 'TV5MONDE, le journal',
|
||||||
'description': 'md5:db15d2e1976641e08377f942778058ea',
|
'description': 'md5:777dc209eaa4423b678477c36b0b04a8',
|
||||||
'upload_date': '20210819',
|
'thumbnail': 'https://psi.tv5monde.com/media/image/960px/6184105.jpg',
|
||||||
'series': "Vestiaires",
|
'duration': 854,
|
||||||
'episode': 'Caro actrice',
|
'upload_date': '20240508',
|
||||||
|
'timestamp': 1715159640,
|
||||||
|
'series': 'TV5MONDE, le journal',
|
||||||
|
'episode': 'EDITION DU 08/05/24 - 11H',
|
||||||
},
|
},
|
||||||
'params': {
|
|
||||||
'skip_download': True,
|
|
||||||
},
|
|
||||||
'skip': 'no longer available',
|
|
||||||
}, {
|
|
||||||
'url': 'https://revoir.tv5monde.com/toutes-les-videos/series-fictions/neuf-jours-en-hiver-neuf-jours-en-hiver',
|
|
||||||
'only_matching': True,
|
|
||||||
}, {
|
|
||||||
'url': 'https://revoir.tv5monde.com/toutes-les-videos/info-societe/le-journal-de-la-rts-edition-du-30-01-20-19h30',
|
|
||||||
'only_matching': True,
|
|
||||||
}]
|
}]
|
||||||
_GEO_BYPASS = False
|
_GEO_BYPASS = False
|
||||||
|
|
||||||
|
@ -98,7 +101,6 @@ class TV5MondePlusIE(InfoExtractor):
|
||||||
if ">Ce programme n'est malheureusement pas disponible pour votre zone géographique.<" in webpage:
|
if ">Ce programme n'est malheureusement pas disponible pour votre zone géographique.<" in webpage:
|
||||||
self.raise_geo_restricted(countries=['FR'])
|
self.raise_geo_restricted(countries=['FR'])
|
||||||
|
|
||||||
title = episode = self._html_search_regex(r'<h1>([^<]+)', webpage, 'title')
|
|
||||||
vpl_data = extract_attributes(self._search_regex(
|
vpl_data = extract_attributes(self._search_regex(
|
||||||
r'(<[^>]+class="video_player_loader"[^>]+>)',
|
r'(<[^>]+class="video_player_loader"[^>]+>)',
|
||||||
webpage, 'video player loader'))
|
webpage, 'video player loader'))
|
||||||
|
@ -147,26 +149,7 @@ class TV5MondePlusIE(InfoExtractor):
|
||||||
process_video_files(video_files)
|
process_video_files(video_files)
|
||||||
|
|
||||||
metadata = self._parse_json(
|
metadata = self._parse_json(
|
||||||
vpl_data['data-metadata'], display_id)
|
vpl_data.get('data-metadata') or '{}', display_id, fatal=False)
|
||||||
duration = (int_or_none(try_get(metadata, lambda x: x['content']['duration']))
|
|
||||||
or parse_duration(self._html_search_meta('duration', webpage)))
|
|
||||||
|
|
||||||
description = self._html_search_regex(
|
|
||||||
r'(?s)<div[^>]+class=["\']episode-texte[^>]+>(.+?)</div>', webpage,
|
|
||||||
'description', fatal=False)
|
|
||||||
|
|
||||||
series = self._html_search_regex(
|
|
||||||
r'<p[^>]+class=["\']episode-emission[^>]+>([^<]+)', webpage,
|
|
||||||
'series', default=None)
|
|
||||||
|
|
||||||
if series and series != title:
|
|
||||||
title = '%s - %s' % (series, title)
|
|
||||||
|
|
||||||
upload_date = self._search_regex(
|
|
||||||
r'(?:date_publication|publish_date)["\']\s*:\s*["\'](\d{4}_\d{2}_\d{2})',
|
|
||||||
webpage, 'upload date', default=None)
|
|
||||||
if upload_date:
|
|
||||||
upload_date = upload_date.replace('_', '')
|
|
||||||
|
|
||||||
if not video_id:
|
if not video_id:
|
||||||
video_id = self._search_regex(
|
video_id = self._search_regex(
|
||||||
|
@ -175,16 +158,20 @@ class TV5MondePlusIE(InfoExtractor):
|
||||||
default=display_id)
|
default=display_id)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
**traverse_obj(metadata, ('content', {
|
||||||
|
'id': ('id', {str}),
|
||||||
|
'title': ('title', {str}),
|
||||||
|
'episode': ('title', {str}),
|
||||||
|
'series': ('series', {str}),
|
||||||
|
'timestamp': ('publishDate_ts', {int_or_none}),
|
||||||
|
'duration': ('duration', {int_or_none}),
|
||||||
|
})),
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'display_id': display_id,
|
'display_id': display_id,
|
||||||
'title': title,
|
'title': clean_html(get_element_by_class('main-title', webpage)),
|
||||||
'description': description,
|
'description': clean_html(get_element_by_class('text', get_element_html_by_class('ep-summary', webpage) or '')),
|
||||||
'thumbnail': vpl_data.get('data-image'),
|
'thumbnail': url_or_none(vpl_data.get('data-image')),
|
||||||
'duration': duration,
|
|
||||||
'upload_date': upload_date,
|
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
'subtitles': self._extract_subtitles(self._parse_json(
|
'subtitles': self._extract_subtitles(self._parse_json(
|
||||||
traverse_obj(vpl_data, ('data-captions', {str}), default='{}'), display_id, fatal=False)),
|
traverse_obj(vpl_data, ('data-captions', {str}), default='{}'), display_id, fatal=False)),
|
||||||
'series': series,
|
|
||||||
'episode': episode,
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue