]>
Commit | Line | Data |
---|---|---|
9b8ee23b | 1 | # flake8: noqa: F401 |
2 | ||
3 | try: | |
4 | import brotlicffi as brotli | |
5 | except ImportError: | |
6 | try: | |
7 | import brotli | |
8 | except ImportError: | |
9 | brotli = None | |
10 | ||
11 | ||
12 | try: | |
13 | import certifi | |
14 | except ImportError: | |
15 | certifi = None | |
16 | else: | |
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 | ||
24 | try: | |
25 | from Cryptodome.Cipher import AES as Cryptodome_AES | |
26 | except ImportError: | |
27 | try: | |
28 | from Crypto.Cipher import AES as Cryptodome_AES | |
29 | except ImportError: | |
30 | Cryptodome_AES = None | |
31 | ||
32 | ||
33 | try: | |
34 | import mutagen | |
35 | except ImportError: | |
36 | mutagen = None | |
37 | ||
38 | ||
39 | secretstorage = None | |
40 | try: | |
41 | import secretstorage | |
42 | _SECRETSTORAGE_UNAVAILABLE_REASON = None | |
43 | except ImportError: | |
44 | _SECRETSTORAGE_UNAVAILABLE_REASON = ( | |
45 | 'as the `secretstorage` module is not installed. ' | |
46 | 'Please install by running `python3 -m pip install secretstorage`') | |
47 | except Exception as _err: | |
48 | _SECRETSTORAGE_UNAVAILABLE_REASON = f'as the `secretstorage` module could not be initialized. {_err}' | |
49 | ||
50 | ||
51 | try: | |
52 | import sqlite3 | |
53 | except 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 | ||
59 | try: | |
60 | import websockets | |
61 | except (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 | ||
67 | all_dependencies = {k: v for k, v in globals().items() if not k.startswith('_')} | |
68 | ||
69 | ||
70 | available_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 | ] |