Merge pull request #7320 from remitamine/adobetv
[youtube-dl] / youtube_dl / extractor / youku.py
index 220f84221817b7da9925273fb90620d300d8f17f..69ecc837a4d6d94c82a1055cb7cc41d6e6663763 100644 (file)
@@ -4,12 +4,13 @@ from __future__ import unicode_literals
 import base64
 
 from .common import InfoExtractor
-from ..utils import ExtractorError
-
 from ..compat import (
     compat_urllib_parse,
     compat_ord,
-    compat_urllib_request,
+)
+from ..utils import (
+    ExtractorError,
+    sanitized_Request,
 )
 
 
@@ -54,9 +55,9 @@ class YoukuIE(InfoExtractor):
         'note': 'Video protected with password',
         'info_dict': {
             'id': 'XNjA1NzA2Njgw',
-            'ext': 'flv',
-            'title': u'邢義田复旦讲座之想象中的胡人—从“左衽孔子”说起',
+            'title': '邢義田复旦讲座之想象中的胡人—从“左衽孔子”说起',
         },
+        'playlist_count': 19,
         'params': {
             'videopassword': '100600',
         },
@@ -187,7 +188,7 @@ class YoukuIE(InfoExtractor):
         video_id = self._match_id(url)
 
         def retrieve_data(req_url, note):
-            req = compat_urllib_request.Request(req_url)
+            req = sanitized_Request(req_url)
 
             cn_verification_proxy = self._downloader.params.get('cn_verification_proxy')
             if cn_verification_proxy:
@@ -199,14 +200,13 @@ class YoukuIE(InfoExtractor):
         video_password = self._downloader.params.get('videopassword', None)
 
         # request basic data
+        basic_data_url = 'http://v.youku.com/player/getPlayList/VideoIDS/%s' % video_id
         if video_password:
-            data1 = retrieve_data(
-                'http://v.youku.com/player/getPlayList/VideoIDS/%s?password=%s' % (video_id, video_password),
-                'Downloading JSON metadata 1')
-        else:
-            data1 = retrieve_data(
-                'http://v.youku.com/player/getPlayList/VideoIDS/%s' % video_id,
-                'Downloading JSON metadata 1')
+            basic_data_url += '?password=%s' % video_password
+
+        data1 = retrieve_data(
+            basic_data_url,
+            'Downloading JSON metadata 1')
         data2 = retrieve_data(
             'http://v.youku.com/player/getPlayList/VideoIDS/%s/Pf/4/ctype/12/ev/1' % video_id,
             'Downloading JSON metadata 2')