From e021db8db6bcc620e017a6c52c8f37b33ce7c266 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Van=C4=9Bk?= Date: Tue, 14 Jan 2020 18:38:11 +0100 Subject: [PATCH] [televizeseznam] handle possible redirects Co-Authored-By: Ales Jirasek <6615474+schunka@users.noreply.github.com> --- youtube_dl/extractor/televizeseznam.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/youtube_dl/extractor/televizeseznam.py b/youtube_dl/extractor/televizeseznam.py index 80a0eece3..8c9ae80b5 100644 --- a/youtube_dl/extractor/televizeseznam.py +++ b/youtube_dl/extractor/televizeseznam.py @@ -75,8 +75,13 @@ class TelevizeSeznamIE(InfoExtractor): headers={'Content-Type': 'application/json;charset=UTF-8'} )['data'] - spl_url = data['episode']['spl'] - play_list = self._download_json(spl_url + 'spl2,3', video_id, 'Downloading playlist')['data'] + spl_url = data['episode']['spl'] + 'spl2,3' + metadata = self._download_json(spl_url, video_id, 'Downloading playlist') + if 'Location' in metadata and 'data' not in metadata: + # they sometimes wants to redirect + spl_url = metadata['Location'] + metadata = self._download_json(spl_url, video_id, 'Redirected -> Downloading playlist') + play_list = metadata['data'] subtitles = self.extract_subtitles(spl_url, play_list.get('subtitles')) formats = self.extract_formats(spl_url, play_list['mp4'], subtitles)