]> gitweb @ CieloNegro.org - youtube-dl.git/commitdiff
[youtube] Improve unavailable message extraction (refs #22117)
authorSergey M․ <dstftw@gmail.com>
Fri, 16 Aug 2019 16:36:23 +0000 (23:36 +0700)
committerSergey M․ <dstftw@gmail.com>
Fri, 16 Aug 2019 16:44:11 +0000 (23:44 +0700)
youtube_dl/extractor/youtube.py

index b63f19bb00554616ebf862d5a875f68d06e01dc8..57d76a5a2521b60c05ca24eecd359b4fc22566d4 100644 (file)
@@ -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()