1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-22 08:34:32 +01:00

Handle subtitles properly

The subtitles are parsed from each mediaselector playlist in the form of a dict keyed by language each of whose values is a list containing a dict keyed by url and sttl type. There seems to be no attempt in the extractor to make this list contain more than one dict. So a strategy is needed to deal with multiple sttl types for the same language.

For backward compatibility, let the first of any duplicate sttl languages take precedence.
This commit is contained in:
dirkf 2020-10-13 13:38:45 +00:00 committed by GitHub
parent 94f4d75bf6
commit 9b74c4b7db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -359,12 +359,17 @@ class BBCCoUkIE(InfoExtractor):
try:
formatsAndSubtitles = self._download_media_selector_url(
mediaselector_url % programme_id, programme_id)
# formats should always be set, but just in case
# formats (a list) should always be set, but just in case
if formatsAndSubtitles[0]:
formats += formatsAndSubtitles[0]
# subtitles may never be set
# subtitles subtitles (a dict {(lang,sttl)})
if formatsAndSubtitles[1]:
subtitles += formatsAndSubtitles[1]
if not subtitles:
subtitles = formatsAndSubtitles[1]
else:
# prioritise the first sttl for each lang
formatsAndSubtitles[1].update(subtitles)
subtitles = formatsAndSubtitles[1]
except BBCCoUkIE.MediaSelectionError as e:
if e.id in ('notukerror', 'geolocation', 'selectionunavailable'):
last_exception = e