mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-23 09:01:43 +00:00
[ie/TV5MondePlus] Fix extractor (#7952)
Closes #4978 Authored by: korli, dirkf
This commit is contained in:
parent
98eac0e6ba
commit
7d3d658f4c
@ -1,10 +1,14 @@
|
|||||||
|
import urllib.parse
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
determine_ext,
|
determine_ext,
|
||||||
extract_attributes,
|
extract_attributes,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
parse_duration,
|
parse_duration,
|
||||||
|
traverse_obj,
|
||||||
try_get,
|
try_get,
|
||||||
|
url_or_none,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -12,6 +16,36 @@ class TV5MondePlusIE(InfoExtractor):
|
|||||||
IE_DESC = 'TV5MONDE+'
|
IE_DESC = 'TV5MONDE+'
|
||||||
_VALID_URL = r'https?://(?:www\.)?(?:tv5mondeplus|revoir\.tv5monde)\.com/toutes-les-videos/[^/]+/(?P<id>[^/?#]+)'
|
_VALID_URL = r'https?://(?:www\.)?(?:tv5mondeplus|revoir\.tv5monde)\.com/toutes-les-videos/[^/]+/(?P<id>[^/?#]+)'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
|
# movie
|
||||||
|
'url': 'https://revoir.tv5monde.com/toutes-les-videos/cinema/les-novices',
|
||||||
|
'md5': 'c86f60bf8b75436455b1b205f9745955',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'ZX0ipMyFQq_6D4BA7b',
|
||||||
|
'display_id': 'les-novices',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'Les novices',
|
||||||
|
'description': 'md5:2e7c33ba3ad48dabfcc2a956b88bde2b',
|
||||||
|
'upload_date': '20230821',
|
||||||
|
'thumbnail': 'https://revoir.tv5monde.com/uploads/media/video_thumbnail/0738/60/01e952b7ccf36b7c6007ec9131588954ab651de9.jpeg',
|
||||||
|
'duration': 5177,
|
||||||
|
'episode': 'Les novices',
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
# series episode
|
||||||
|
'url': 'https://revoir.tv5monde.com/toutes-les-videos/series-fictions/opj-les-dents-de-la-terre-2',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'wJ0eeEPozr_6D4BA7b',
|
||||||
|
'display_id': 'opj-les-dents-de-la-terre-2',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': "OPJ - Les dents de la Terre (2)",
|
||||||
|
'description': 'md5:288f87fd68d993f814e66e60e5302d9d',
|
||||||
|
'upload_date': '20230823',
|
||||||
|
'series': 'OPJ',
|
||||||
|
'episode': 'Les dents de la Terre (2)',
|
||||||
|
'duration': 2877,
|
||||||
|
'thumbnail': 'https://dl-revoir.tv5monde.com/images/1a/5753448.jpg'
|
||||||
|
},
|
||||||
|
}, {
|
||||||
# movie
|
# movie
|
||||||
'url': 'https://revoir.tv5monde.com/toutes-les-videos/cinema/ceux-qui-travaillent',
|
'url': 'https://revoir.tv5monde.com/toutes-les-videos/cinema/ceux-qui-travaillent',
|
||||||
'md5': '32fa0cde16a4480d1251502a66856d5f',
|
'md5': '32fa0cde16a4480d1251502a66856d5f',
|
||||||
@ -23,6 +57,7 @@ class TV5MondePlusIE(InfoExtractor):
|
|||||||
'description': 'md5:570e8bb688036ace873b2d50d24c026d',
|
'description': 'md5:570e8bb688036ace873b2d50d24c026d',
|
||||||
'upload_date': '20210819',
|
'upload_date': '20210819',
|
||||||
},
|
},
|
||||||
|
'skip': 'no longer available',
|
||||||
}, {
|
}, {
|
||||||
# series episode
|
# series episode
|
||||||
'url': 'https://revoir.tv5monde.com/toutes-les-videos/series-fictions/vestiaires-caro-actrice',
|
'url': 'https://revoir.tv5monde.com/toutes-les-videos/series-fictions/vestiaires-caro-actrice',
|
||||||
@ -39,6 +74,7 @@ class TV5MondePlusIE(InfoExtractor):
|
|||||||
'params': {
|
'params': {
|
||||||
'skip_download': True,
|
'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',
|
'url': 'https://revoir.tv5monde.com/toutes-les-videos/series-fictions/neuf-jours-en-hiver-neuf-jours-en-hiver',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
@ -63,20 +99,45 @@ def _real_extract(self, url):
|
|||||||
video_files = self._parse_json(
|
video_files = self._parse_json(
|
||||||
vpl_data['data-broadcast'], display_id)
|
vpl_data['data-broadcast'], display_id)
|
||||||
formats = []
|
formats = []
|
||||||
for video_file in video_files:
|
video_id = None
|
||||||
v_url = video_file.get('url')
|
|
||||||
if not v_url:
|
def process_video_files(v):
|
||||||
continue
|
nonlocal video_id
|
||||||
video_format = video_file.get('format') or determine_ext(v_url)
|
for video_file in v:
|
||||||
if video_format == 'm3u8':
|
v_url = video_file.get('url')
|
||||||
formats.extend(self._extract_m3u8_formats(
|
if not v_url:
|
||||||
v_url, display_id, 'mp4', 'm3u8_native',
|
continue
|
||||||
m3u8_id='hls', fatal=False))
|
if video_file.get('type') == 'application/deferred':
|
||||||
else:
|
d_param = urllib.parse.quote(v_url)
|
||||||
formats.append({
|
token = video_file.get('token')
|
||||||
'url': v_url,
|
if not token:
|
||||||
'format_id': video_format,
|
continue
|
||||||
})
|
deferred_json = self._download_json(
|
||||||
|
f'https://api.tv5monde.com/player/asset/{d_param}/resolve?condenseKS=true', display_id,
|
||||||
|
note='Downloading deferred info', headers={'Authorization': f'Bearer {token}'}, fatal=False)
|
||||||
|
v_url = traverse_obj(deferred_json, (0, 'url', {url_or_none}))
|
||||||
|
if not v_url:
|
||||||
|
continue
|
||||||
|
# data-guid from the webpage isn't stable, use the material id from the json urls
|
||||||
|
video_id = self._search_regex(
|
||||||
|
r'materials/([\da-zA-Z]{10}_[\da-fA-F]{7})/', v_url, 'video id', default=None)
|
||||||
|
process_video_files(deferred_json)
|
||||||
|
|
||||||
|
video_format = video_file.get('format') or determine_ext(v_url)
|
||||||
|
if video_format == 'm3u8':
|
||||||
|
formats.extend(self._extract_m3u8_formats(
|
||||||
|
v_url, display_id, 'mp4', 'm3u8_native',
|
||||||
|
m3u8_id='hls', fatal=False))
|
||||||
|
elif video_format == 'mpd':
|
||||||
|
formats.extend(self._extract_mpd_formats(
|
||||||
|
v_url, display_id, fatal=False))
|
||||||
|
else:
|
||||||
|
formats.append({
|
||||||
|
'url': v_url,
|
||||||
|
'format_id': video_format,
|
||||||
|
})
|
||||||
|
|
||||||
|
process_video_files(video_files)
|
||||||
|
|
||||||
metadata = self._parse_json(
|
metadata = self._parse_json(
|
||||||
vpl_data['data-metadata'], display_id)
|
vpl_data['data-metadata'], display_id)
|
||||||
@ -100,10 +161,11 @@ def _real_extract(self, url):
|
|||||||
if upload_date:
|
if upload_date:
|
||||||
upload_date = upload_date.replace('_', '')
|
upload_date = upload_date.replace('_', '')
|
||||||
|
|
||||||
video_id = self._search_regex(
|
if not video_id:
|
||||||
(r'data-guid=["\']([\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12})',
|
video_id = self._search_regex(
|
||||||
r'id_contenu["\']\s:\s*(\d+)'), webpage, 'video id',
|
(r'data-guid=["\']([\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12})',
|
||||||
default=display_id)
|
r'id_contenu["\']\s:\s*(\d+)'), webpage, 'video id',
|
||||||
|
default=display_id)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
|
Loading…
Reference in New Issue
Block a user