[lynda] Capture and output login error (Closes #6556)
authorSergey M․ <dstftw@gmail.com>
Fri, 14 Aug 2015 16:07:02 +0000 (22:07 +0600)
committerSergey M․ <dstftw@gmail.com>
Fri, 14 Aug 2015 16:07:02 +0000 (22:07 +0600)
youtube_dl/extractor/lynda.py

index deead220af21bd5e37deab93446dc9e9cac59ba8..5b9157ed43efb0169baac327ce37ec7d46eb69f5 100644 (file)
@@ -11,6 +11,7 @@ from ..compat import (
 )
 from ..utils import (
     ExtractorError,
+    clean_html,
     int_or_none,
 )
 
@@ -70,6 +71,15 @@ class LyndaBaseIE(InfoExtractor):
                     'Confirming log in and log out from another device')
 
         if all(not re.search(p, login_page) for p in ('isLoggedIn\s*:\s*true', r'logout\.aspx', r'>Log out<')):
+            if 'login error' in login_page:
+                mobj = re.search(
+                    r'(?s)<h1[^>]+class="topmost">(?P<title>[^<]+)</h1>\s*<div>(?P<description>.+?)</div>',
+                    login_page)
+                if mobj:
+                    raise ExtractorError(
+                        'lynda returned error: %s - %s'
+                        % (mobj.group('title'), clean_html(mobj.group('description'))),
+                        expected=True)
             raise ExtractorError('Unable to log in')