]> jfr.im git - yt-dlp.git/blame - yt_dlp/dependencies.py
[doc] Minor improvements
[yt-dlp.git] / yt_dlp / dependencies.py
CommitLineData
9b8ee23b 1# flake8: noqa: F401
2
3try:
4 import brotlicffi as brotli
5except ImportError:
6 try:
7 import brotli
8 except ImportError:
9 brotli = None
10
11
12try:
13 import certifi
14except ImportError:
15 certifi = None
16else:
17 from os.path import exists as _path_exists
18
19 # The certificate may not be bundled in executable
20 if not _path_exists(certifi.where()):
21 certifi = None
22
23
24try:
25 from Cryptodome.Cipher import AES as Cryptodome_AES
26except ImportError:
27 try:
28 from Crypto.Cipher import AES as Cryptodome_AES
29 except ImportError:
30 Cryptodome_AES = None
31
32
33try:
34 import mutagen
35except ImportError:
36 mutagen = None
37
38
39secretstorage = None
40try:
41 import secretstorage
42 _SECRETSTORAGE_UNAVAILABLE_REASON = None
43except ImportError:
44 _SECRETSTORAGE_UNAVAILABLE_REASON = (
45 'as the `secretstorage` module is not installed. '
46 'Please install by running `python3 -m pip install secretstorage`')
47except Exception as _err:
48 _SECRETSTORAGE_UNAVAILABLE_REASON = f'as the `secretstorage` module could not be initialized. {_err}'
49
50
51try:
52 import sqlite3
53except ImportError:
54 # although sqlite3 is part of the standard library, it is possible to compile python without
55 # sqlite support. See: https://github.com/yt-dlp/yt-dlp/issues/544
56 sqlite3 = None
57
58
59try:
60 import websockets
61except (ImportError, SyntaxError):
62 # websockets 3.10 on python 3.6 causes SyntaxError
63 # See https://github.com/yt-dlp/yt-dlp/issues/2633
64 websockets = None
65
66
67all_dependencies = {k: v for k, v in globals().items() if not k.startswith('_')}
68
69
70available_dependencies = {k: v for k, v in all_dependencies.items() if v}
71
72
73__all__ = [
74 'all_dependencies',
75 'available_dependencies',
76 *all_dependencies.keys(),
77]