[letv] LetvCloud: check error messages from server
authorYen Chi Hsuan <yan12125@gmail.com>
Tue, 19 Jan 2016 19:31:34 +0000 (03:31 +0800)
committerYen Chi Hsuan <yan12125@gmail.com>
Tue, 19 Jan 2016 19:31:34 +0000 (03:31 +0800)
youtube_dl/extractor/letv.py

index b8d4f5bb8ca02482504a9d8eca0a188542f311a1..177d53bbb07b577375a89a5ace1c711b3c237d4e 100644 (file)
@@ -287,6 +287,14 @@ class LetvCloudIE(InfoExtractor):
             'uu=' + uu + '&vu=' + vu)
         play_json = self._download_json(play_json_req, media_id, 'Downloading playJson data')
 
+        if not play_json.get('data'):
+            if play_json.get('message'):
+                raise ExtractorError('Letv cloud said: %s' % play_json['message'], expected=True)
+            elif play_json.get('code'):
+                raise ExtractorError('Letv cloud returned error %d' % play_json['code'], expected=True)
+            else:
+                raise ExtractorError('Letv cloud returned an unknwon error')
+
         formats = []
         for media in play_json['data']['video_info']['media'].values():
             play_url = media['play_url']