diff --git a/docs/configuration.rst b/docs/configuration.rst index 303a3d07..680919bd 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -5184,11 +5184,15 @@ Description extractor.ytdl.module --------------------- Type - ``string`` + * ``string`` + * |Path|_ Default ``null`` +Example + * ``"yt-dlp"`` + * ``"/home/user/.local/lib/python3.13/site-packages/youtube_dl"`` Description - Name of the ``ytdl`` Python module to import. + Name or filesystem path of the ``ytdl`` Python module to import. Setting this to ``null`` will try to import ``"yt_dlp"`` followed by ``"youtube_dl"`` as fallback. @@ -5644,11 +5648,15 @@ Description downloader.ytdl.module ---------------------- Type - ``string`` + * ``string`` + * |Path|_ Default ``null`` +Example + * ``"yt-dlp"`` + * ``"/home/user/.local/lib/python3.13/site-packages/youtube_dl"`` Description - Name of the ``ytdl`` Python module to import. + Name or filesystem path of the ``ytdl`` Python module to import. Setting this to ``null`` will try to import ``"yt_dlp"`` followed by ``"youtube_dl"`` as fallback. diff --git a/gallery_dl/util.py b/gallery_dl/util.py index 23020881..7034c0cb 100644 --- a/gallery_dl/util.py +++ b/gallery_dl/util.py @@ -770,7 +770,7 @@ def import_file(path): finally: del sys.path[0] else: - return __import__(name) + return __import__(name.replace("-", "_")) def build_duration_func(duration, min=0.0): diff --git a/gallery_dl/ytdl.py b/gallery_dl/ytdl.py index 32545e26..319e7812 100644 --- a/gallery_dl/ytdl.py +++ b/gallery_dl/ytdl.py @@ -20,7 +20,7 @@ def import_module(module_name): return __import__("yt_dlp") except (ImportError, SyntaxError): return __import__("youtube_dl") - return __import__(module_name.replace("-", "_")) + return util.import_file(module_name) def construct_YoutubeDL(module, obj, user_opts, system_opts=None):