mirror of
				https://github.com/yt-dlp/yt-dlp.git
				synced 2025-10-30 22:25:19 +00:00 
			
		
		
		
	[dependencies] Create module with all dependency imports
This commit is contained in:
		| @@ -41,7 +41,6 @@ import zlib | ||||
| 
 | ||||
| from .compat import ( | ||||
|     asyncio, | ||||
|     compat_brotli, | ||||
|     compat_chr, | ||||
|     compat_cookiejar, | ||||
|     compat_etree_fromstring, | ||||
| @@ -64,18 +63,10 @@ from .compat import ( | ||||
|     compat_urllib_parse_urlparse, | ||||
|     compat_urllib_request, | ||||
|     compat_urlparse, | ||||
|     compat_websockets, | ||||
| ) | ||||
| from .dependencies import brotli, certifi, websockets | ||||
| from .socks import ProxyType, sockssocket | ||||
| 
 | ||||
| try: | ||||
|     import certifi | ||||
| 
 | ||||
|     # The certificate may not be bundled in executable | ||||
|     has_certifi = os.path.exists(certifi.where()) | ||||
| except ImportError: | ||||
|     has_certifi = False | ||||
| 
 | ||||
| 
 | ||||
| def register_socks_protocols(): | ||||
|     # "Register" SOCKS protocols | ||||
| @@ -138,7 +129,7 @@ def random_user_agent(): | ||||
| SUPPORTED_ENCODINGS = [ | ||||
|     'gzip', 'deflate' | ||||
| ] | ||||
| if compat_brotli: | ||||
| if brotli: | ||||
|     SUPPORTED_ENCODINGS.append('br') | ||||
| 
 | ||||
| std_headers = { | ||||
| @@ -1267,7 +1258,7 @@ class YoutubeDLHandler(compat_urllib_request.HTTPHandler): | ||||
|     def brotli(data): | ||||
|         if not data: | ||||
|             return data | ||||
|         return compat_brotli.decompress(data) | ||||
|         return brotli.decompress(data) | ||||
| 
 | ||||
|     def http_request(self, req): | ||||
|         # According to RFC 3986, URLs can not contain non-ASCII characters, however this is not | ||||
| @@ -5231,7 +5222,7 @@ class WebSocketsWrapper(): | ||||
| 
 | ||||
|     def __init__(self, url, headers=None, connect=True): | ||||
|         self.loop = asyncio.events.new_event_loop() | ||||
|         self.conn = compat_websockets.connect( | ||||
|         self.conn = websockets.connect( | ||||
|             url, extra_headers=headers, ping_interval=None, | ||||
|             close_timeout=float('inf'), loop=self.loop, ping_timeout=float('inf')) | ||||
|         if connect: | ||||
| @@ -5294,9 +5285,6 @@ class WebSocketsWrapper(): | ||||
|                 }) | ||||
| 
 | ||||
| 
 | ||||
| has_websockets = bool(compat_websockets) | ||||
| 
 | ||||
| 
 | ||||
| def merge_headers(*dicts): | ||||
|     """Merge dicts of http headers case insensitively, prioritizing the latter ones""" | ||||
|     return {k.title(): v for k, v in itertools.chain.from_iterable(map(dict.items, dicts))} | ||||
| @@ -5312,3 +5300,8 @@ class classproperty: | ||||
| 
 | ||||
| def Namespace(**kwargs): | ||||
|     return collections.namedtuple('Namespace', kwargs)(**kwargs) | ||||
| 
 | ||||
| 
 | ||||
| # Deprecated | ||||
| has_certifi = bool(certifi) | ||||
| has_websockets = bool(websockets) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 pukkandan
					pukkandan