1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-25 03:32:05 +00:00

[youtube] Improve error detection (#16445)

This commit is contained in:
Sergey M․ 2019-08-06 02:32:44 +07:00
parent eb9c9c74a6
commit 1357734978
No known key found for this signature in database
GPG key ID: 2C393E0F18A9236D

View file

@ -1813,7 +1813,8 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
def extract_unavailable_message(): def extract_unavailable_message():
return self._html_search_regex( return self._html_search_regex(
r'(?s)<h1[^>]+id="unavailable-message"[^>]*>(.+?)</h1>', (r'(?s)<div[^>]+id=["\']unavailable-submessage["\'][^>]+>(.+?)</div',
r'(?s)<h1[^>]+id=["\']unavailable-message["\'][^>]*>(.+?)</h1>'),
video_webpage, 'unavailable message', default=None) video_webpage, 'unavailable message', default=None)
if not video_info: if not video_info:
@ -2098,9 +2099,14 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
a_format.setdefault('http_headers', {})['Youtubedl-no-compression'] = 'True' a_format.setdefault('http_headers', {})['Youtubedl-no-compression'] = 'True'
formats.append(a_format) formats.append(a_format)
else: else:
error_message = clean_html(video_info.get('reason', [None])[0]) error_message = extract_unavailable_message()
if not error_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: if error_message:
raise ExtractorError(error_message, expected=True) raise ExtractorError(error_message, expected=True)
raise ExtractorError('no conn, hlsvp, hlsManifestUrl or url_encoded_fmt_stream_map information found in video info') raise ExtractorError('no conn, hlsvp, hlsManifestUrl or url_encoded_fmt_stream_map information found in video info')