1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-29 19:47:54 +01:00

[CCMA] Fix multiple subtitles incompatibility

CCMA extractor used to raise an exception when attempting the download of
a URL featuring multiple languages in the subtitles.

When a single language is available, the field is the expected dict.
When multiple languages are available, a list of dicts is provided.

This commit fixes this issue.
This commit is contained in:
Guillem Vela 2020-02-27 22:27:21 +01:00
parent 69c4e35907
commit 8c60c29d34

View File

@ -92,12 +92,15 @@ class CCMAIE(InfoExtractor):
timestamp = parse_iso8601(data_iso8601) timestamp = parse_iso8601(data_iso8601)
subtitles = {} subtitles = {}
subtitols = media.get('subtitols', {}) subtitols = media.get('subtitols', [])
if subtitols: # Single language -> dict; multiple languages -> List[dict]
sub_url = subtitols.get('url') if isinstance(subtitols, dict):
subtitols = [subtitols]
for st in subtitols:
sub_url = st.get('url')
if sub_url: if sub_url:
subtitles.setdefault( subtitles.setdefault(
subtitols.get('iso') or subtitols.get('text') or 'ca', []).append({ st.get('iso') or 'ca', []).append({
'url': sub_url, 'url': sub_url,
}) })