- data1_url = 'http://v.youku.com/player/getPlayList/VideoIDS/%s' % video_id
- data2_url = 'http://v.youku.com/player/getPlayList/VideoIDS/%s/Pf/4/ctype/12/ev/1' % video_id
-
- raw_data1 = self._download_json(data1_url, video_id)
- raw_data2 = self._download_json(data2_url, video_id)
- data1 = raw_data1['data'][0]
- data2 = raw_data2['data'][0]
-
- error_code = data1.get('error_code')
- if error_code:
- # -8 means blocked outside China.
- # Chinese and English, separated by newline.
- error = data1.get('error')
- raise ExtractorError(
- error or 'Server reported error %i' %
- error_code,
- expected=True)
-
- title = data1['title']
+ basic_data_url = "http://play.youku.com/play/get.json?vid=%s&ct=12" % video_id
+ if video_password:
+ basic_data_url += '&pwd=%s' % video_password
+
+ data = retrieve_data(basic_data_url, 'Downloading JSON metadata')
+
+ error = data.get('error')
+ if error:
+ error_note = error.get('note')
+ if error_note is not None and '因版权原因无法观看此视频' in error_note:
+ raise ExtractorError(
+ 'Youku said: Sorry, this video is available in China only', expected=True)
+ elif error_note and '该视频被设为私密' in error_note:
+ raise ExtractorError(
+ 'Youku said: Sorry, this video is private', expected=True)
+ else:
+ msg = 'Youku server reported error %i' % error.get('code')
+ if error_note is not None:
+ msg += ': ' + error_note
+ raise ExtractorError(msg)
+
+ # get video title
+ title = data['video']['title']