]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/dependencies.py
[extractor] Framework for embed detection (#4307)
[yt-dlp.git] / yt_dlp / dependencies.py
index 99cc6e29c2e27cc4855ccfbddb6eeb93a67c89c6..5a5363adb1eb29494b3e91a20f038af7a1a913d3 100644 (file)
@@ -1,4 +1,6 @@
 # flake8: noqa: F401
+"""Imports all optional dependencies for the project.
+An attribute "_yt_dlp__identifier" may be inserted into the module if it uses an ambiguous namespace"""
 
 try:
     import brotlicffi as brotli
 except ImportError:
     try:
         from Crypto.Cipher import AES as Cryptodome_AES
-    except ImportError:
+    except (ImportError, SyntaxError):  # Old Crypto gives SyntaxError in newer Python
         Cryptodome_AES = None
+    else:
+        try:
+            # In pycrypto, mode defaults to ECB. See:
+            # https://www.pycryptodome.org/en/latest/src/vs_pycrypto.html#:~:text=not%20have%20ECB%20as%20default%20mode
+            Cryptodome_AES.new(b'abcdefghijklmnop')
+        except TypeError:
+            pass
+        else:
+            Cryptodome_AES._yt_dlp__identifier = 'pycrypto'
 
 
 try:
     websockets = None
 
 
+try:
+    import xattr  # xattr or pyxattr
+except ImportError:
+    xattr = None
+else:
+    if hasattr(xattr, 'set'):  # pyxattr
+        xattr._yt_dlp__identifier = 'pyxattr'
+
+
 all_dependencies = {k: v for k, v in globals().items() if not k.startswith('_')}