Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ytdl] add 'module-loction' option #6991

Closed
wants to merge 3 commits into from

Conversation

RadicalRingtail
Copy link

this is an option to specify a directory to import either the yt-dlp or youtube-dl module from (meant to address this issue, which i encountered today after updating gallery-dl to the latest version: #4729)

this change also renames the ytdl 'module' option to 'module-name' to prevent confusion as to what each of these 2 options do

+ renamed ytdl 'module' opition to 'module-name' to be more explicit in naming convention and avoid confusion
@mikf
Copy link
Owner

mikf commented Feb 14, 2025

PYTHONPATH exists.


I think this would be a lot simpler by re-using the existing module option and using it with the util.import_file() function, which supports file system paths as well as module names, instead of plain __import__().

diff --git a/gallery_dl/ytdl.py b/gallery_dl/ytdl.py
index 32545e26..4f0303d8 100644
--- a/gallery_dl/ytdl.py
+++ b/gallery_dl/ytdl.py
@@ -21,5 +21,5 @@ def import_module(module_name):
         except (ImportError, SyntaxError):
             return __import__("youtube_dl")
-    return __import__(module_name.replace("-", "_"))
+    return util.import_file(module_name.replace("-", "_"))
 
 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants