mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-09-05 18:39:37 +02:00
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
import importlib
|
|
|
|
from ..compat import functools
|
|
from ..compat.compat_utils import EnhancedModule, passthrough_module
|
|
|
|
EnhancedModule(__name__)
|
|
|
|
try:
|
|
import Cryptodome as _parent
|
|
except ImportError:
|
|
try:
|
|
import Crypto as _parent
|
|
except (ImportError, SyntaxError): # Old Crypto gives SyntaxError in newer Python
|
|
_parent = EnhancedModule('Cryptodome')
|
|
__bool__ = lambda: False
|
|
|
|
|
|
@functools.cache
|
|
def __getattr__(name):
|
|
try:
|
|
submodule = importlib.import_module(f'.{name}', _parent.__name__)
|
|
except ImportError:
|
|
return getattr(_parent, name)
|
|
return passthrough_module(f'{__name__}.{name}', submodule)
|
|
|
|
|
|
@property
|
|
@functools.cache
|
|
def _yt_dlp__identifier():
|
|
if _parent.__name__ == 'Crypto':
|
|
from Crypto.Cipher import AES
|
|
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
|
|
AES.new(b'abcdefghijklmnop')
|
|
except TypeError:
|
|
return 'pycrypto'
|
|
return _parent.__name__
|