From 8c60c29d341f9291b81f850e0c4b7b20fb15f96a Mon Sep 17 00:00:00 2001 From: Guillem Vela Date: Thu, 27 Feb 2020 22:27:21 +0100 Subject: [PATCH] [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. --- youtube_dl/extractor/ccma.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/youtube_dl/extractor/ccma.py b/youtube_dl/extractor/ccma.py index f7f6de5c8..d4873860a 100644 --- a/youtube_dl/extractor/ccma.py +++ b/youtube_dl/extractor/ccma.py @@ -92,12 +92,15 @@ class CCMAIE(InfoExtractor): timestamp = parse_iso8601(data_iso8601) subtitles = {} - subtitols = media.get('subtitols', {}) - if subtitols: - sub_url = subtitols.get('url') + subtitols = media.get('subtitols', []) + # Single language -> dict; multiple languages -> List[dict] + if isinstance(subtitols, dict): + subtitols = [subtitols] + for st in subtitols: + sub_url = st.get('url') if sub_url: subtitles.setdefault( - subtitols.get('iso') or subtitols.get('text') or 'ca', []).append({ + st.get('iso') or 'ca', []).append({ 'url': sub_url, })