mirror of https://github.com/yt-dlp/yt-dlp
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
2.0 KiB
Python
84 lines
2.0 KiB
Python
3 years ago
|
# flake8: noqa: F401
|
||
3 years ago
|
"""Imports all optional dependencies for the project.
|
||
3 years ago
|
An attribute "_yt_dlp__identifier" may be inserted into the module if it uses an ambiguous namespace"""
|
||
3 years ago
|
|
||
|
try:
|
||
|
import brotlicffi as brotli
|
||
|
except ImportError:
|
||
|
try:
|
||
|
import brotli
|
||
|
except ImportError:
|
||
|
brotli = None
|
||
|
|
||
|
|
||
|
try:
|
||
|
import certifi
|
||
|
except ImportError:
|
||
|
certifi = None
|
||
|
else:
|
||
|
from os.path import exists as _path_exists
|
||
|
|
||
|
# The certificate may not be bundled in executable
|
||
|
if not _path_exists(certifi.where()):
|
||
|
certifi = None
|
||
|
|
||
|
|
||
|
try:
|
||
|
import mutagen
|
||
|
except ImportError:
|
||
|
mutagen = None
|
||
|
|
||
|
|
||
|
secretstorage = None
|
||
|
try:
|
||
|
import secretstorage
|
||
|
_SECRETSTORAGE_UNAVAILABLE_REASON = None
|
||
|
except ImportError:
|
||
|
_SECRETSTORAGE_UNAVAILABLE_REASON = (
|
||
|
'as the `secretstorage` module is not installed. '
|
||
|
'Please install by running `python3 -m pip install secretstorage`')
|
||
|
except Exception as _err:
|
||
|
_SECRETSTORAGE_UNAVAILABLE_REASON = f'as the `secretstorage` module could not be initialized. {_err}'
|
||
|
|
||
|
|
||
|
try:
|
||
|
import sqlite3
|
||
|
except ImportError:
|
||
|
# although sqlite3 is part of the standard library, it is possible to compile python without
|
||
|
# sqlite support. See: https://github.com/yt-dlp/yt-dlp/issues/544
|
||
|
sqlite3 = None
|
||
|
|
||
|
|
||
|
try:
|
||
|
import websockets
|
||
|
except (ImportError, SyntaxError):
|
||
|
# websockets 3.10 on python 3.6 causes SyntaxError
|
||
|
# See https://github.com/yt-dlp/yt-dlp/issues/2633
|
||
|
websockets = None
|
||
|
|
||
|
|
||
3 years ago
|
try:
|
||
|
import xattr # xattr or pyxattr
|
||
|
except ImportError:
|
||
|
xattr = None
|
||
|
else:
|
||
|
if hasattr(xattr, 'set'): # pyxattr
|
||
|
xattr._yt_dlp__identifier = 'pyxattr'
|
||
|
|
||
|
|
||
2 years ago
|
from . import Cryptodome
|
||
|
|
||
3 years ago
|
all_dependencies = {k: v for k, v in globals().items() if not k.startswith('_')}
|
||
2 years ago
|
available_dependencies = {k: v for k, v in all_dependencies.items() if v}
|
||
3 years ago
|
|
||
|
|
||
2 years ago
|
# Deprecated
|
||
|
Cryptodome_AES = Cryptodome.Cipher.AES if Cryptodome else None
|
||
3 years ago
|
|
||
|
|
||
|
__all__ = [
|
||
|
'all_dependencies',
|
||
|
'available_dependencies',
|
||
|
*all_dependencies.keys(),
|
||
|
]
|