]> gitweb @ CieloNegro.org - youtube-dl.git/commitdiff
[YoutubeDL] Wrap plain-text URL requests in compat_urllib_request_Request
authorSergey M․ <dstftw@gmail.com>
Thu, 19 Nov 2015 21:08:34 +0000 (03:08 +0600)
committerSergey M․ <dstftw@gmail.com>
Mon, 23 Nov 2015 15:55:13 +0000 (21:55 +0600)
youtube_dl/YoutubeDL.py

index fba99af8dce2143e7cc8feba3a61460f2b029839..b20837ce288c7d1b182ab4b4fc83f18804851823 100755 (executable)
@@ -28,6 +28,7 @@ if os.name == 'nt':
     import ctypes
 
 from .compat import (
+    compat_basestring,
     compat_cookiejar,
     compat_expanduser,
     compat_get_terminal_size,
@@ -38,6 +39,7 @@ from .compat import (
     compat_urllib_error,
     compat_urllib_request,
     compat_urllib_request_DataHandler,
+    compat_urllib_request_Request,
 )
 from .utils import (
     ContentTooShortError,
@@ -1871,6 +1873,8 @@ class YoutubeDL(object):
 
     def urlopen(self, req):
         """ Start an HTTP download """
+        if isinstance(req, compat_basestring):
+            req = compat_urllib_request_Request(req)
         return self._opener.open(req, timeout=self._socket_timeout)
 
     def print_debug_header(self):