extractors.py 791 B

123456789101112131415161718192021222324252627
  1. import contextlib
  2. import os
  3. from ..utils import load_plugins
  4. # NB: Must be before other imports so that plugins can be correctly injected
  5. _PLUGIN_CLASSES = load_plugins('extractor', 'IE', {})
  6. _LAZY_LOADER = False
  7. if not os.environ.get('YTDLP_NO_LAZY_EXTRACTORS'):
  8. with contextlib.suppress(ImportError):
  9. from .lazy_extractors import * # noqa: F403
  10. from .lazy_extractors import _ALL_CLASSES
  11. _LAZY_LOADER = True
  12. if not _LAZY_LOADER:
  13. from ._extractors import * # noqa: F403
  14. _ALL_CLASSES = [ # noqa: F811
  15. klass
  16. for name, klass in globals().items()
  17. if name.endswith('IE') and name != 'GenericIE'
  18. ]
  19. _ALL_CLASSES.append(GenericIE) # noqa: F405
  20. globals().update(_PLUGIN_CLASSES)
  21. _ALL_CLASSES[:0] = _PLUGIN_CLASSES.values()