mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-17 15:08:49 +01:00
8e40b9d1ec
to make plugins easier to develop and use: * Plugins are now loaded as namespace packages. * Plugins can be loaded in any distribution of yt-dlp (binary, pip, source, etc.). * Plugin packages can be installed and managed via pip, or dropped into any of the documented locations. * Users do not need to edit any code files to install plugins. * Backwards-compatible with previous plugin architecture. As a side-effect, yt-dlp will now search in a few more locations for config files. Closes https://github.com/yt-dlp/yt-dlp/issues/1389 Authored by: flashdagger, coletdjnz, pukkandan, Grub4K Co-authored-by: Marcel <flashdagger@googlemail.com> Co-authored-by: pukkandan <pukkandan.ytdlp@gmail.com> Co-authored-by: Simon Sawicki <accounts@grub4k.xyz>
27 lines
789 B
Python
27 lines
789 B
Python
import contextlib
|
|
import os
|
|
|
|
from ..plugins import load_plugins
|
|
|
|
# NB: Must be before other imports so that plugins can be correctly injected
|
|
_PLUGIN_CLASSES = load_plugins('extractor', 'IE')
|
|
|
|
_LAZY_LOADER = False
|
|
if not os.environ.get('YTDLP_NO_LAZY_EXTRACTORS'):
|
|
with contextlib.suppress(ImportError):
|
|
from .lazy_extractors import * # noqa: F403
|
|
from .lazy_extractors import _ALL_CLASSES
|
|
_LAZY_LOADER = True
|
|
|
|
if not _LAZY_LOADER:
|
|
from ._extractors import * # noqa: F403
|
|
_ALL_CLASSES = [ # noqa: F811
|
|
klass
|
|
for name, klass in globals().items()
|
|
if name.endswith('IE') and name != 'GenericIE'
|
|
]
|
|
_ALL_CLASSES.append(GenericIE) # noqa: F405
|
|
|
|
globals().update(_PLUGIN_CLASSES)
|
|
_ALL_CLASSES[:0] = _PLUGIN_CLASSES.values()
|