From bc478ec1e3467f383bf409857c83e2e2d6a48bcd Mon Sep 17 00:00:00 2001 From: thePanz Date: Wed, 18 Dec 2019 19:41:38 +0100 Subject: [PATCH] Handle relative subtitle URLs --- youtube_dl/extractor/rai.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/youtube_dl/extractor/rai.py b/youtube_dl/extractor/rai.py index 15f0f22d3..93cadd53c 100644 --- a/youtube_dl/extractor/rai.py +++ b/youtube_dl/extractor/rai.py @@ -125,12 +125,17 @@ class RaiBaseIE(InfoExtractor): def _extract_subtitles_from_list(subtitle_array, subtitles): if isinstance(subtitle_array, list): for item in subtitle_array: - lang = item.get('language') - url = item.get('url') - if url_or_none(url) and str_or_none(lang): - subtitles[lang.lower()] = [{ - 'ext': url[-3:], - 'url': url, + subtitle_lang = item.get('language') + subtitle_url = item.get('url') + + # Handle relative subtitles URL + if None == url_or_none(subtitle_url): + subtitle_url = 'https://www.raiplay.it'+subtitle_url + + if url_or_none(subtitle_url) and str_or_none(subtitle_lang): + subtitles[subtitle_lang.lower()] = [{ + 'ext': subtitle_url[-3:], + 'url': subtitle_url, }] return subtitles @@ -183,7 +188,6 @@ class RaiPlayIE(RaiBaseIE): url, video_id = mobj.group('url', 'id') media = self._download_json(url.replace('.html', '.json'), video_id, 'Downloading video JSON') - title = media['name'] video = media['video']