From 1ad6dd845b4af1d238b5bc3308cbe47060e1ab7b Mon Sep 17 00:00:00 2001 From: dirkf Date: Tue, 6 Oct 2020 17:31:06 +0100 Subject: [PATCH] Try all possible mediaselectors even if one succeeds Some mediaselectors may be parseable but have no formats (eg captions only). This revision tries all possible mediaselectors and assembles the formats and subtitles found. If any formats are found, the known exceptions ('notukerror', 'geolocation', 'selectionunavailable') are not propagated. --- youtube_dl/extractor/bbc.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/youtube_dl/extractor/bbc.py b/youtube_dl/extractor/bbc.py index 002c39c39..ca0634e6c 100644 --- a/youtube_dl/extractor/bbc.py +++ b/youtube_dl/extractor/bbc.py @@ -350,16 +350,26 @@ class BBCCoUkIE(InfoExtractor): def _download_media_selector(self, programme_id): last_exception = None + formats = [] + subtitles = [] + # as some mediaselectors may be parseable but have + # no formats (eg captions only), try all possible + # mediaselectors for mediaselector_url in self._MEDIASELECTOR_URLS: try: - return self._download_media_selector_url( + formatsAndSubtitles = self._download_media_selector_url( mediaselector_url % programme_id, programme_id) + formats += formatsAndSubtitles[0] + subtitles += formatsAndSubtitles[1] except BBCCoUkIE.MediaSelectionError as e: if e.id in ('notukerror', 'geolocation', 'selectionunavailable'): last_exception = e continue self._raise_extractor_error(e) - self._raise_extractor_error(last_exception) + # ignore a trapped exception if formats were found + if last_exception and not formats: + self._raise_extractor_error(last_exception) + return formats, subtitles def _download_media_selector_url(self, url, programme_id=None): media_selection = self._download_xml(