]> jfr.im git - yt-dlp.git/commitdiff
[Plugins] Prioritize plugins over standard extractors
authorpukkandan <redacted>
Sat, 8 May 2021 15:15:14 +0000 (20:45 +0530)
committerpukkandan <redacted>
Sat, 8 May 2021 22:52:27 +0000 (04:22 +0530)
and prevent plugins from overwriting the standard extractor classes

Closes #304

yt_dlp/extractor/__init__.py
yt_dlp/utils.py

index 38f6df18167a9d7e2acb14b6969c004e8087a93b..7d540540e242b3d6f0ab79bb9dad2c8c45b1e3b0 100644 (file)
@@ -12,9 +12,6 @@
 
 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 @@
     ]
     _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.
index baa2a415e4f83005a66a8ddb9a79ae8b116a556e..b80a8cedb319f11a08ab369f707f8727a27e89e8 100644 (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)