extractors.py 842 B

12345678910111213141516171819202122232425262728
  1. import contextlib
  2. import os
  3. from ..plugins 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()
  22. from .common import _PLUGIN_OVERRIDES # noqa: F401