Skip to content

Commit

Permalink
[ytdl] support specifying filesystem paths as 'module' (#6991)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Feb 14, 2025
1 parent 7ae09c6 commit 182b544
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
16 changes: 12 additions & 4 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion gallery_dl/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion gallery_dl/ytdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 182b544

Please sign in to comment.