[twitch] Fix error message regex
authorSergey M․ <dstftw@gmail.com>
Fri, 10 Jul 2015 15:15:09 +0000 (21:15 +0600)
committerSergey M․ <dstftw@gmail.com>
Fri, 10 Jul 2015 15:15:09 +0000 (21:15 +0600)
youtube_dl/extractor/twitch.py

index b7a72a7bdccf74bc3027e0930d262d5c173a4aec..f912d3825e65046e33068f34aafce63eaa07f235 100644 (file)
@@ -74,11 +74,12 @@ class TwitchBaseIE(InfoExtractor):
         response = self._download_webpage(
             request, None, 'Logging in as %s' % username)
 
-        m = re.search(
-            r"id=([\"'])login_error_message\1[^>]*>(?P<msg>[^<]+)", response)
-        if m:
+        error_message = self._search_regex(
+            r'<div[^>]+class="subwindow_notice"[^>]*>([^<]+)</div>',
+            response, 'error message', default=None)
+        if error_message:
             raise ExtractorError(
-                'Unable to login: %s' % m.group('msg').strip(), expected=True)
+                'Unable to login. Twitch said: %s' % error_message, expected=True)
 
     def _prefer_source(self, formats):
         try: