mirror of
https://codeberg.org/polarisfm/youtube-dl
synced 2024-11-29 19:47:54 +01:00
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.
This commit is contained in:
parent
d65d89183f
commit
1ad6dd845b
@ -350,16 +350,26 @@ class BBCCoUkIE(InfoExtractor):
|
|||||||
|
|
||||||
def _download_media_selector(self, programme_id):
|
def _download_media_selector(self, programme_id):
|
||||||
last_exception = None
|
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:
|
for mediaselector_url in self._MEDIASELECTOR_URLS:
|
||||||
try:
|
try:
|
||||||
return self._download_media_selector_url(
|
formatsAndSubtitles = self._download_media_selector_url(
|
||||||
mediaselector_url % programme_id, programme_id)
|
mediaselector_url % programme_id, programme_id)
|
||||||
|
formats += formatsAndSubtitles[0]
|
||||||
|
subtitles += formatsAndSubtitles[1]
|
||||||
except BBCCoUkIE.MediaSelectionError as e:
|
except BBCCoUkIE.MediaSelectionError as e:
|
||||||
if e.id in ('notukerror', 'geolocation', 'selectionunavailable'):
|
if e.id in ('notukerror', 'geolocation', 'selectionunavailable'):
|
||||||
last_exception = e
|
last_exception = e
|
||||||
continue
|
continue
|
||||||
self._raise_extractor_error(e)
|
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):
|
def _download_media_selector_url(self, url, programme_id=None):
|
||||||
media_selection = self._download_xml(
|
media_selection = self._download_xml(
|
||||||
|
Loading…
Reference in New Issue
Block a user