2022-04-21 00:35:57 +05:30
|
|
|
# flake8: noqa: F401
|
2022-04-29 07:18:36 +05:30
|
|
|
"""Imports all optional dependencies for the project.
|
2022-06-26 20:50:06 -04:00
|
|
|
An attribute "_yt_dlp__identifier" may be inserted into the module if it uses an ambiguous namespace"""
|
2022-04-21 00:35:57 +05:30
|
|
|
|
|
|
|
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
|
2023-09-21 10:58:53 -05:00
|
|
|
# We need to get the underlying `sqlite` version, see https://github.com/yt-dlp/yt-dlp/issues/8152
|
|
|
|
sqlite3._yt_dlp__version = sqlite3.sqlite_version
|
2022-04-21 00:35:57 +05:30
|
|
|
except ImportError:
|
2024-03-11 00:48:47 +05:30
|
|
|
# although sqlite3 is part of the standard library, it is possible to compile Python without
|
2022-04-21 00:35:57 +05:30
|
|
|
# sqlite support. See: https://github.com/yt-dlp/yt-dlp/issues/544
|
|
|
|
sqlite3 = None
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
import websockets
|
2024-03-10 22:28:37 +05:30
|
|
|
except ImportError:
|
2022-04-21 00:35:57 +05:30
|
|
|
websockets = None
|
|
|
|
|
2023-10-14 12:33:00 +13:00
|
|
|
try:
|
|
|
|
import urllib3
|
|
|
|
except ImportError:
|
|
|
|
urllib3 = None
|
|
|
|
|
|
|
|
try:
|
|
|
|
import requests
|
|
|
|
except ImportError:
|
|
|
|
requests = None
|
2022-04-21 00:35:57 +05:30
|
|
|
|
2022-05-01 04:46:05 +05:30
|
|
|
try:
|
|
|
|
import xattr # xattr or pyxattr
|
|
|
|
except ImportError:
|
|
|
|
xattr = None
|
|
|
|
else:
|
|
|
|
if hasattr(xattr, 'set'): # pyxattr
|
|
|
|
xattr._yt_dlp__identifier = 'pyxattr'
|
|
|
|
|
2024-03-16 22:52:38 -05:00
|
|
|
try:
|
|
|
|
import curl_cffi
|
|
|
|
except ImportError:
|
|
|
|
curl_cffi = None
|
2022-05-01 04:46:05 +05:30
|
|
|
|
2023-02-07 03:22:29 +05:30
|
|
|
from . import Cryptodome
|
|
|
|
|
2022-04-21 00:35:57 +05:30
|
|
|
all_dependencies = {k: v for k, v in globals().items() if not k.startswith('_')}
|
2023-02-07 03:22:29 +05:30
|
|
|
available_dependencies = {k: v for k, v in all_dependencies.items() if v}
|
2022-04-21 00:35:57 +05:30
|
|
|
|
|
|
|
|
2023-02-07 03:22:29 +05:30
|
|
|
# Deprecated
|
2023-02-28 23:10:54 +05:30
|
|
|
Cryptodome_AES = Cryptodome.AES
|
2022-04-21 00:35:57 +05:30
|
|
|
|
|
|
|
|
|
|
|
__all__ = [
|
|
|
|
'all_dependencies',
|
|
|
|
'available_dependencies',
|
|
|
|
*all_dependencies.keys(),
|
|
|
|
]
|