2022-04-20 19:05:57 +00:00
|
|
|
# flake8: noqa: F401
|
2022-04-29 01:48:36 +00:00
|
|
|
"""Imports all optional dependencies for the project.
|
2022-06-27 00:50:06 +00:00
|
|
|
An attribute "_yt_dlp__identifier" may be inserted into the module if it uses an ambiguous namespace"""
|
2022-04-20 19:05:57 +00:00
|
|
|
|
|
|
|
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 15:58:53 +00: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-20 19:05:57 +00:00
|
|
|
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
|
|
|
|
|
2023-10-13 23:33:00 +00:00
|
|
|
try:
|
|
|
|
import urllib3
|
|
|
|
except ImportError:
|
|
|
|
urllib3 = None
|
|
|
|
|
|
|
|
try:
|
|
|
|
import requests
|
|
|
|
except ImportError:
|
|
|
|
requests = None
|
2022-04-20 19:05:57 +00:00
|
|
|
|
2022-04-30 23:16:05 +00:00
|
|
|
try:
|
|
|
|
import xattr # xattr or pyxattr
|
|
|
|
except ImportError:
|
|
|
|
xattr = None
|
|
|
|
else:
|
|
|
|
if hasattr(xattr, 'set'): # pyxattr
|
|
|
|
xattr._yt_dlp__identifier = 'pyxattr'
|
|
|
|
|
|
|
|
|
2023-02-06 21:52:29 +00:00
|
|
|
from . import Cryptodome
|
|
|
|
|
2022-04-20 19:05:57 +00:00
|
|
|
all_dependencies = {k: v for k, v in globals().items() if not k.startswith('_')}
|
2023-02-06 21:52:29 +00:00
|
|
|
available_dependencies = {k: v for k, v in all_dependencies.items() if v}
|
2022-04-20 19:05:57 +00:00
|
|
|
|
|
|
|
|
2023-02-06 21:52:29 +00:00
|
|
|
# Deprecated
|
2023-02-28 17:40:54 +00:00
|
|
|
Cryptodome_AES = Cryptodome.AES
|
2022-04-20 19:05:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
__all__ = [
|
|
|
|
'all_dependencies',
|
|
|
|
'available_dependencies',
|
|
|
|
*all_dependencies.keys(),
|
|
|
|
]
|