From 135773497857f04469219e97a5d09350f61672b0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sergey=20M=E2=80=A4?= Date: Tue, 6 Aug 2019 02:32:44 +0700 Subject: [PATCH] [youtube] Improve error detection (#16445) --- youtube_dl/extractor/youtube.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py index 1aee0e465..44740cb75 100644 --- a/youtube_dl/extractor/youtube.py +++ b/youtube_dl/extractor/youtube.py @@ -1813,7 +1813,8 @@ class YoutubeIE(YoutubeBaseInfoExtractor): def extract_unavailable_message(): return self._html_search_regex( - r'(?s)]+id="unavailable-message"[^>]*>(.+?)', + (r'(?s)]+id=["\']unavailable-submessage["\'][^>]+>(.+?)]+id=["\']unavailable-message["\'][^>]*>(.+?)'), video_webpage, 'unavailable message', default=None) if not video_info: @@ -2098,9 +2099,14 @@ class YoutubeIE(YoutubeBaseInfoExtractor): a_format.setdefault('http_headers', {})['Youtubedl-no-compression'] = 'True' formats.append(a_format) else: - error_message = clean_html(video_info.get('reason', [None])[0]) + error_message = extract_unavailable_message() if not error_message: - error_message = extract_unavailable_message() + error_message = clean_html(try_get( + player_response, lambda x: x['playabilityStatus']['reason'], + compat_str)) + if not error_message: + error_message = clean_html( + try_get(video_info, lambda x: x['reason'][0], compat_str)) if error_message: raise ExtractorError(error_message, expected=True) raise ExtractorError('no conn, hlsvp, hlsManifestUrl or url_encoded_fmt_stream_map information found in video info') -- 2.22.2