aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor
diff options
context:
space:
mode:
authorSergey M. <dstftw@gmail.com>2014-02-25 20:29:16 +0700
committerSergey M. <dstftw@gmail.com>2014-02-25 20:30:17 +0700
commit1d430674c7ad8341d2025f43f93c4f582d1f92ea (patch)
tree78a6a89251cd5169cc52ce6c98f9cfc342adc37d /youtube_dl/extractor
parent70cb73922b532c20925e725aa0243305c4caaac6 (diff)
[crunchyroll] Handle error message
Diffstat (limited to 'youtube_dl/extractor')
-rw-r--r--youtube_dl/extractor/crunchyroll.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/youtube_dl/extractor/crunchyroll.py b/youtube_dl/extractor/crunchyroll.py
index 44d78fe5e..5587ade12 100644
--- a/youtube_dl/extractor/crunchyroll.py
+++ b/youtube_dl/extractor/crunchyroll.py
@@ -2,6 +2,7 @@
from __future__ import unicode_literals
import re
+import json
import base64
import zlib
@@ -113,6 +114,12 @@ class CrunchyrollIE(InfoExtractor):
if note_m:
raise ExtractorError(note_m)
+ mobj = re.search(r'Page\.messaging_box_controller\.addItems\(\[(?P<msg>{.+?})\]\)', webpage)
+ if mobj:
+ msg = json.loads(mobj.group('msg'))
+ if msg.get('type') == 'error':
+ raise ExtractorError('crunchyroll returned error: %s' % msg['message_body'], 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='')