[crunchyroll] Detect required login (#6677)
authorSergey M․ <dstftw@gmail.com>
Wed, 26 Aug 2015 14:47:57 +0000 (20:47 +0600)
committerSergey M․ <dstftw@gmail.com>
Wed, 26 Aug 2015 14:47:57 +0000 (20:47 +0600)
youtube_dl/extractor/crunchyroll.py

index 33a033a7f3175fec3b85725841581d2ac252033d..98d1881aeff51b3a670952a8314fa98c7c242cc1 100644 (file)
@@ -237,7 +237,9 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
             webpage_url = 'http://www.' + mobj.group('url')
 
         webpage = self._download_webpage(webpage_url, video_id, 'Downloading webpage')
-        note_m = self._html_search_regex(r'<div class="showmedia-trailer-notice">(.+?)</div>', webpage, 'trailer-notice', default='')
+        note_m = self._html_search_regex(
+            r'<div class="showmedia-trailer-notice">(.+?)</div>',
+            webpage, 'trailer-notice', default='')
         if note_m:
             raise ExtractorError(note_m)
 
@@ -247,6 +249,12 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
             if msg.get('type') == 'error':
                 raise ExtractorError('crunchyroll returned error: %s' % msg['message_body'], expected=True)
 
+        if 'To view this, please log in to verify you are 18 or older.' in webpage:
+            raise ExtractorError(
+                'This video is only available for registered users, '
+                'use --username and --password options to provide account credentials.',
+                expected=True)
+
         video_title = self._html_search_regex(r'<h1[^>]*>(.+?)</h1>', webpage, 'video_title', flags=re.DOTALL)
         video_title = re.sub(r' {2,}', ' ', video_title)
         video_description = self._html_search_regex(r'"description":"([^"]+)', webpage, 'video_description', default='')