aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortewe <tewe@github>2013-09-15 21:58:49 +0200
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>2013-09-21 20:50:31 +0200
commit4a2080e4077e9e12c860d82a4d2eebc75c1ea54b (patch)
tree492903358c15606eea4e9e78f833af656f28a41f
parentb00ca882a4c1069de1ec2d04ffd50905c0f8b97f (diff)
[youku] better error handling
blocked videos used to cause death by TypeError, now we report what the server says
-rw-r--r--youtube_dl/extractor/youku.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/youtube_dl/extractor/youku.py b/youtube_dl/extractor/youku.py
index 996d38478..00fa2ccb5 100644
--- a/youtube_dl/extractor/youku.py
+++ b/youtube_dl/extractor/youku.py
@@ -66,6 +66,12 @@ class YoukuIE(InfoExtractor):
self.report_extraction(video_id)
try:
config = json.loads(jsondata)
+ error_code = config['data'][0].get('error_code')
+ if error_code:
+ # -8 means blocked outside China.
+ error = config['data'][0].get('error') # Chinese and English, separated by newline.
+ raise ExtractorError(error or u'Server reported error %i' % error_code,
+ expected=True)
video_title = config['data'][0]['title']
seed = config['data'][0]['seed']
@@ -89,6 +95,7 @@ class YoukuIE(InfoExtractor):
fileid = config['data'][0]['streamfileids'][format]
keys = [s['k'] for s in config['data'][0]['segs'][format]]
+ # segs is usually a dictionary, but an empty *list* if an error occured.
except (UnicodeDecodeError, ValueError, KeyError):
raise ExtractorError(u'Unable to extract info section')