From 6b8eb0c024af2caff2f972424ec1195500896e5a Mon Sep 17 00:00:00 2001 From: pukkandan Date: Mon, 25 Jan 2021 10:26:51 +0530 Subject: [PATCH] Report error message from youtube as error (Closes #33) :ci skip dl --- youtube_dlc/extractor/youtube.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/youtube_dlc/extractor/youtube.py b/youtube_dlc/extractor/youtube.py index 20657bb19..7f3485db7 100644 --- a/youtube_dlc/extractor/youtube.py +++ b/youtube_dlc/extractor/youtube.py @@ -3371,8 +3371,16 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor): webpage = self._download_webpage(url, item_id) identity_token = self._extract_identity_token(webpage, item_id) data = self._extract_yt_initial_data(item_id, webpage) + err_msg = None for alert_type, alert_message in self._extract_alerts(data): - self._downloader.report_warning('YouTube said: %s - %s' % (alert_type, alert_message)) + if alert_type.lower() == 'error': + if err_msg: + self._downloader.report_warning('YouTube said: %s - %s' % ('ERROR', err_msg)) + err_msg = alert_message + else: + self._downloader.report_warning('YouTube said: %s - %s' % (alert_type, alert_message)) + if err_msg: + raise ExtractorError('YouTube said: %s' % err_msg, expected=True) tabs = try_get( data, lambda x: x['contents']['twoColumnBrowseResultsRenderer']['tabs'], list) if tabs: