From f9b8b0bccba0966c1c0185e64754ff79ad6241c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20S=C3=A1nchez=20Siles?= Date: Tue, 11 May 2021 22:51:12 +0200 Subject: [PATCH 1/5] [extractors]: Split rtve imports. --- youtube_dl/extractor/extractors.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 6e8fc3961..7fd1fb867 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -1025,7 +1025,12 @@ from .rtl2 import ( ) from .rtp import RTPIE from .rts import RTSIE -from .rtve import RTVEALaCartaIE, RTVELiveIE, RTVEInfantilIE, RTVELiveIE, RTVETelevisionIE +from .rtve import ( + RTVEALaCartaIE, + RTVELiveIE, + RTVEInfantilIE, + RTVETelevisionIE, +) from .rtvnh import RTVNHIE from .rtvs import RTVSIE from .ruhd import RUHDIE From 571d02cd5ef6fb873e0b2328a1cd0531035d3849 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20S=C3=A1nchez=20Siles?= Date: Tue, 11 May 2021 22:53:28 +0200 Subject: [PATCH 2/5] [rtve]: Add support for audio only urls. --- youtube_dl/extractor/extractors.py | 1 + youtube_dl/extractor/rtve.py | 34 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 7fd1fb867..6f115e8f9 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -1028,6 +1028,7 @@ from .rts import RTSIE from .rtve import ( RTVEALaCartaIE, RTVELiveIE, + RTVEAudioIE, RTVEInfantilIE, RTVETelevisionIE, ) diff --git a/youtube_dl/extractor/rtve.py b/youtube_dl/extractor/rtve.py index d2fb754cf..f86d17fab 100644 --- a/youtube_dl/extractor/rtve.py +++ b/youtube_dl/extractor/rtve.py @@ -179,6 +179,40 @@ class RTVEALaCartaIE(InfoExtractor): for s in subs) +class RTVEAudioIE(RTVEALaCartaIE): + IE_NAME = 'rtve.es:audio' + IE_DESC = 'RTVE audio' + _VALID_URL = r'https?://(?:www\.)?rtve\.es/alacarta/audios/[^/]+/[^/]+/(?P[0-9]+)/' + + _TESTS = [{ + 'url': 'https://www.rtve.es/alacarta/audios/a-hombros-de-gigantes/palabra-ingeniero-codigos-informaticos-27-04-21/5889192/', + 'md5': 'ae06d27bff945c4e87a50f89f6ce48ce', + 'info_dict': { + 'id': '5889192', + 'ext': 'mp3', + 'title': 'Códigos informáticos', + 'thumbnail': r're:https?://.+/1598856591583.jpg', + 'duration': 349.440, + }, + }] + + def _real_extract(self, url): + audio_id = self._match_id(url) + info = self._download_json( + 'https://www.rtve.es/api/audios/%s.json' % audio_id, + audio_id)['page']['items'][0] + title = info['title'].strip() + + return { + 'id': audio_id, + 'title': title, + 'thumbnail': info.get('thumbnail'), + 'duration': float_or_none(info.get('duration'), 1000), + 'series': info.get('programInfo').get('title'), + 'url': info.get('qualities')[0].get('filePath'), + } + + class RTVEInfantilIE(RTVEALaCartaIE): IE_NAME = 'rtve.es:infantil' IE_DESC = 'RTVE infantil' From 894578ee7415883eb8a9f3364efabdb182124c0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20S=C3=A1nchez=20Siles?= Date: Tue, 12 Oct 2021 22:16:29 +0200 Subject: [PATCH 3/5] [rtve]: Add support for audio rtve play. --- youtube_dl/extractor/rtve.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/rtve.py b/youtube_dl/extractor/rtve.py index f86d17fab..fca0783dc 100644 --- a/youtube_dl/extractor/rtve.py +++ b/youtube_dl/extractor/rtve.py @@ -182,7 +182,7 @@ class RTVEALaCartaIE(InfoExtractor): class RTVEAudioIE(RTVEALaCartaIE): IE_NAME = 'rtve.es:audio' IE_DESC = 'RTVE audio' - _VALID_URL = r'https?://(?:www\.)?rtve\.es/alacarta/audios/[^/]+/[^/]+/(?P[0-9]+)/' + _VALID_URL = r'https?://(?:www\.)?rtve\.es/(alacarta|play)/audios/[^/]+/[^/]+/(?P[0-9]+)/' _TESTS = [{ 'url': 'https://www.rtve.es/alacarta/audios/a-hombros-de-gigantes/palabra-ingeniero-codigos-informaticos-27-04-21/5889192/', @@ -194,6 +194,16 @@ class RTVEAudioIE(RTVEALaCartaIE): 'thumbnail': r're:https?://.+/1598856591583.jpg', 'duration': 349.440, }, + }, { + 'url': 'https://www.rtve.es/play/audios/en-radio-3/ignatius-farray/5791165/', + 'md5': '072855ab89a9450e0ba314c717fa5ebc', + 'info_dict': { + 'id': '5791165', + 'ext': 'mp3', + 'title': 'Ignatius Farray', + 'thumbnail': r're:https?://.+/1613243011863.jpg', + 'duration': 3559.559, + }, }] def _real_extract(self, url): From df4e6b21fa9480c343a6a6b2b4a83e413af81fe0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20S=C3=A1nchez=20Siles?= Date: Tue, 12 Oct 2021 22:20:11 +0200 Subject: [PATCH 4/5] [rtve]: Switch audio extractor to thumbnail parsing so all urls are supported --- youtube_dl/extractor/rtve.py | 40 +++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/rtve.py b/youtube_dl/extractor/rtve.py index fca0783dc..205e9bed0 100644 --- a/youtube_dl/extractor/rtve.py +++ b/youtube_dl/extractor/rtve.py @@ -204,14 +204,52 @@ class RTVEAudioIE(RTVEALaCartaIE): 'thumbnail': r're:https?://.+/1613243011863.jpg', 'duration': 3559.559, }, + }, { + 'url': 'https://www.rtve.es/play/audios/frankenstein-o-el-moderno-prometeo/capitulo-26-ultimo-muerte-victor-juan-jose-plans-mary-shelley/6082623/', + 'md5': '0eadab248cc8dd193fa5765712e84d5c', + 'info_dict': { + 'id': '6082623', + 'ext': 'mp3', + 'title': 'Capítulo 26 y último: La muerte de Victor', + 'thumbnail': r're:https?://.+/1632147445707.jpg', + 'duration': 3174.086, + }, }] + def _extract_png_formats(self, audio_id): + print(__name__, self._manager, audio_id) + png = self._download_webpage( + 'http://www.rtve.es/ztnr/movil/thumbnail/%s/audios/%s.png' % + (self._manager, audio_id), + audio_id, 'Downloading url information', query={'q': 'v2'}) + q = qualities(['Media', 'Alta', 'HQ', 'HD_READY', 'HD_FULL']) + formats = [] + for quality, audio_url in self._decrypt_url(png): + ext = determine_ext(audio_url) + print(quality, audio_url, ext) + if ext == 'm3u8': + formats.extend(self._extract_m3u8_formats( + audio_url, audio_id, 'mp4', 'm3u8_native', + m3u8_id='hls', fatal=False)) + elif ext == 'mpd': + formats.extend(self._extract_mpd_formats( + audio_url, audio_id, 'dash', fatal=False)) + else: + formats.append({ + 'format_id': quality, + 'quality': q(quality), + 'url': audio_url, + }) + self._sort_formats(formats) + return formats + def _real_extract(self, url): audio_id = self._match_id(url) info = self._download_json( 'https://www.rtve.es/api/audios/%s.json' % audio_id, audio_id)['page']['items'][0] title = info['title'].strip() + formats = self._extract_png_formats(audio_id) return { 'id': audio_id, @@ -219,7 +257,7 @@ class RTVEAudioIE(RTVEALaCartaIE): 'thumbnail': info.get('thumbnail'), 'duration': float_or_none(info.get('duration'), 1000), 'series': info.get('programInfo').get('title'), - 'url': info.get('qualities')[0].get('filePath'), + 'formats': formats, } From ca76f4e8eb9c853577e407d3689c10bb12e17674 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20S=C3=A1nchez=20Siles?= Date: Tue, 12 Oct 2021 22:22:30 +0200 Subject: [PATCH 5/5] [rtve]: Remove debug trace in RTVEAudioIE. --- youtube_dl/extractor/rtve.py | 1 - 1 file changed, 1 deletion(-) diff --git a/youtube_dl/extractor/rtve.py b/youtube_dl/extractor/rtve.py index 205e9bed0..649568d6e 100644 --- a/youtube_dl/extractor/rtve.py +++ b/youtube_dl/extractor/rtve.py @@ -217,7 +217,6 @@ class RTVEAudioIE(RTVEALaCartaIE): }] def _extract_png_formats(self, audio_id): - print(__name__, self._manager, audio_id) png = self._download_webpage( 'http://www.rtve.es/ztnr/movil/thumbnail/%s/audios/%s.png' % (self._manager, audio_id),