aboutsummaryrefslogtreecommitdiff
path: root/yt_dlp/YoutubeDL.py
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2022-06-15 18:00:34 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2022-06-16 06:23:50 +0530
commit560738f34de4df6eaf82290fd503def3f366f878 (patch)
treeabaf12930736e70b39a3a1b45500408ca020cf2c /yt_dlp/YoutubeDL.py
parent99d10bf60796a90d2ca421ec63f1208b15ae5f48 (diff)
[extractor] Import `_ALL_CLASSES` lazily
This significantly speeds up `import yt_dlp` in the absence of `lazy_extractors`
Diffstat (limited to 'yt_dlp/YoutubeDL.py')
-rw-r--r--yt_dlp/YoutubeDL.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py
index 7ba6441e1..1932af3fe 100644
--- a/yt_dlp/YoutubeDL.py
+++ b/yt_dlp/YoutubeDL.py
@@ -38,8 +38,6 @@ from .compat import (
from .cookies import load_cookies
from .downloader import FFmpegFD, get_suitable_downloader, shorten_protocol_name
from .downloader.rtmp import rtmpdump_version
-from .extractor import _LAZY_LOADER
-from .extractor import _PLUGIN_CLASSES as plugin_extractors
from .extractor import gen_extractor_classes, get_info_extractor
from .extractor.openload import PhantomJSwrapper
from .minicurses import format_text
@@ -3659,6 +3657,10 @@ class YoutubeDL:
if not self.params.get('verbose'):
return
+ # These imports can be slow. So import them only as needed
+ from .extractor.extractors import _LAZY_LOADER
+ from .extractor.extractors import _PLUGIN_CLASSES as plugin_extractors
+
def get_encoding(stream):
ret = str(getattr(stream, 'encoding', 'missing (%s)' % type(stream).__name__))
if not supports_terminal_sequences(stream):