mirror of
				https://github.com/yt-dlp/yt-dlp.git
				synced 2025-11-04 00:25:15 +00:00 
			
		
		
		
	[YoutubeDL] Wrap plain-text URL requests in compat_urllib_request_Request
This commit is contained in:
		@@ -28,6 +28,7 @@ if os.name == 'nt':
 | 
				
			|||||||
    import ctypes
 | 
					    import ctypes
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from .compat import (
 | 
					from .compat import (
 | 
				
			||||||
 | 
					    compat_basestring,
 | 
				
			||||||
    compat_cookiejar,
 | 
					    compat_cookiejar,
 | 
				
			||||||
    compat_expanduser,
 | 
					    compat_expanduser,
 | 
				
			||||||
    compat_get_terminal_size,
 | 
					    compat_get_terminal_size,
 | 
				
			||||||
@@ -38,6 +39,7 @@ from .compat import (
 | 
				
			|||||||
    compat_urllib_error,
 | 
					    compat_urllib_error,
 | 
				
			||||||
    compat_urllib_request,
 | 
					    compat_urllib_request,
 | 
				
			||||||
    compat_urllib_request_DataHandler,
 | 
					    compat_urllib_request_DataHandler,
 | 
				
			||||||
 | 
					    compat_urllib_request_Request,
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
from .utils import (
 | 
					from .utils import (
 | 
				
			||||||
    ContentTooShortError,
 | 
					    ContentTooShortError,
 | 
				
			||||||
@@ -1871,6 +1873,8 @@ class YoutubeDL(object):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    def urlopen(self, req):
 | 
					    def urlopen(self, req):
 | 
				
			||||||
        """ Start an HTTP download """
 | 
					        """ Start an HTTP download """
 | 
				
			||||||
 | 
					        if isinstance(req, compat_basestring):
 | 
				
			||||||
 | 
					            req = compat_urllib_request_Request(req)
 | 
				
			||||||
        return self._opener.open(req, timeout=self._socket_timeout)
 | 
					        return self._opener.open(req, timeout=self._socket_timeout)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def print_debug_header(self):
 | 
					    def print_debug_header(self):
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user