[Plugins] Prioritize plugins over standard extractors

and prevent plugins from overwriting the standard extractor classes

Closes #304
This commit is contained in:
pukkandan 2021-05-08 20:45:14 +05:30
parent 000ee7ef34
commit 2f567473c6
No known key found for this signature in database
GPG Key ID: 0F00D95A001F4698
2 changed files with 7 additions and 5 deletions

View File

@ -12,9 +12,6 @@ except ImportError:
if not _LAZY_LOADER:
from .extractors import *
_PLUGIN_CLASSES = load_plugins('extractor', 'IE', globals())
_ALL_CLASSES = [
klass
for name, klass in globals().items()
@ -22,6 +19,9 @@ if not _LAZY_LOADER:
]
_ALL_CLASSES.append(GenericIE)
_PLUGIN_CLASSES = load_plugins('extractor', 'IE', globals())
_ALL_CLASSES = _PLUGIN_CLASSES + _ALL_CLASSES
def gen_extractor_classes():
""" Return a list of supported extractors.

View File

@ -6081,7 +6081,7 @@ def get_executable_path():
return os.path.abspath(path)
def load_plugins(name, type, namespace):
def load_plugins(name, suffix, namespace):
plugin_info = [None]
classes = []
try:
@ -6089,7 +6089,9 @@ def load_plugins(name, type, namespace):
name, [os.path.join(get_executable_path(), 'ytdlp_plugins')])
plugins = imp.load_module(name, *plugin_info)
for name in dir(plugins):
if not name.endswith(type):
if name in namespace:
continue
if not name.endswith(suffix):
continue
klass = getattr(plugins, name)
classes.append(klass)