diff options
author | Sergey M․ <dstftw@gmail.com> | 2019-08-16 23:36:23 +0700 |
---|---|---|
committer | Sergey M․ <dstftw@gmail.com> | 2019-08-16 23:44:11 +0700 |
commit | 0add33abcb9eb3ac93f7af312940b033b4ae4168 (patch) | |
tree | 91101c1c9ad2803b4f095c0aabf23aa77c9e9f80 | |
parent | 0326bcb6c1a45067a804d2f32aa854a3fcd9b4ce (diff) |
[youtube] Improve unavailable message extraction (refs #22117)
-rw-r--r-- | youtube_dl/extractor/youtube.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py index b63f19bb0..57d76a5a2 100644 --- a/youtube_dl/extractor/youtube.py +++ b/youtube_dl/extractor/youtube.py @@ -1809,10 +1809,15 @@ class YoutubeIE(YoutubeBaseInfoExtractor): break def extract_unavailable_message(): - return self._html_search_regex( - (r'(?s)<div[^>]+id=["\']unavailable-submessage["\'][^>]+>(.+?)</div', - r'(?s)<h1[^>]+id=["\']unavailable-message["\'][^>]*>(.+?)</h1>'), - video_webpage, 'unavailable message', default=None) + messages = [] + for tag, kind in (('h1', 'message'), ('div', 'submessage')): + msg = self._html_search_regex( + r'(?s)<{tag}[^>]+id=["\']unavailable-{kind}["\'][^>]*>(.+?)</{tag}>'.format(tag=tag, kind=kind), + video_webpage, 'unavailable %s' % kind, default=None) + if msg: + messages.append(msg) + if messages: + return '\n'.join(messages) if not video_info: unavailable_message = extract_unavailable_message() |