From 45a0e17e196c8e13e74f5dfdbad8e72a7add6ba2 Mon Sep 17 00:00:00 2001 From: lonm Date: Thu, 23 Jan 2025 19:41:49 +0000 Subject: [PATCH] [RadioFrance] Include exception case for missing metadata --- yt_dlp/extractor/radiofrance.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/yt_dlp/extractor/radiofrance.py b/yt_dlp/extractor/radiofrance.py index 89680b305a..d6b080069f 100644 --- a/yt_dlp/extractor/radiofrance.py +++ b/yt_dlp/extractor/radiofrance.py @@ -6,13 +6,13 @@ from ..utils import ( join_nonempty, js_to_json, parse_duration, + RegexNotFoundError, strftime_or_none, traverse_obj, unified_strdate, urljoin, ) - class RadioFranceIE(InfoExtractor): _VALID_URL = r'https?://maison\.radiofrance\.fr/radiovisions/(?P[^?#]+)' IE_NAME = 'radiofrance' @@ -286,7 +286,12 @@ class RadioFrancePlaylistBaseIE(RadioFranceBaseIE): for linkkey in links: url = self._search_regex(linkkey + r'\.url="([^"]+)";', webpage, content_id) dur = int(self._search_regex(linkkey + r'\.duration=(\d+);', webpage, content_id)) - preset = self._search_json(linkkey + r'\.preset=', webpage, content_id, content_id, contains_pattern=r'\{.+\}', transform_source=js_to_json) + # Preset describes the audio encoding. Some episodes will be missing a 'preset', simply stating 'null' + # In this case, give a generic response + try: + preset = self._search_json(linkkey + r'\.preset=', webpage, content_id, content_id, contains_pattern=r'\{.+\}', transform_source=js_to_json) + except RegexNotFoundError: + preset = {"id": "999", "name": "unknown format", "encoding": "unknown", "bitrate": "unknown"} item['formats'].append({ 'format_id': preset['id'], 'url': url,