Try all possible mediaselectors even if one succeeds #1

Open
df wants to merge 4 commits from df-bbc-multi-mediaselector-patch into Hummy

View File

@ -350,16 +350,29 @@ 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 = None
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 (a list) should always be set, but just in case
if formatsAndSubtitles[0]:
formats += formatsAndSubtitles[0]
# subtitles (dict {lang,sttl})
if formatsAndSubtitles[1]:
if subtitles:
# prioritise the first sttl for each lang
formatsAndSubtitles[1].update(subtitles)
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) 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(