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

Allow specifying output directory #1185

Merged
merged 2 commits into from
Mar 15, 2021

Conversation

aklajnert
Copy link
Contributor

This is a very small change that'll allow specifying the output directory by specifying -o or --output argument.
Some users were asking for it, and I find it also useful to me.

@aklajnert aklajnert changed the base branch from master to dev February 12, 2021 08:35
@aklajnert aklajnert requested review from a user and Silverarmor February 12, 2021 08:36
@Silverarmor Silverarmor deleted the branch spotDL:dev February 12, 2021 10:37
@Silverarmor Silverarmor reopened this Feb 12, 2021
@Silverarmor Silverarmor requested review from bee395, phcreery and xnetcat and removed request for Silverarmor February 17, 2021 11:27
@phcreery
Copy link
Contributor

I really like this option. My question, why chdir and not modify convertedFilePath of `downloader.py'? I feel like the latter is more explicit and easier to understand.

spotdl/__main__.py Outdated Show resolved Hide resolved
@aklajnert
Copy link
Contributor Author

I really like this option. My question, why chdir and not modify convertedFilePath of `downloader.py'? I feel like the latter is more explicit and easier to understand.

It would complicate the code too much in my opinion. Simply changing the working directory is very easy and works just fine.

@bee395
Copy link
Contributor

bee395 commented Feb 21, 2021

I tested it on Linux and it works fine.

When I specify a folder without permission, I get a PermissionError with traceback, but since it's short and clear to understand what went wrong, I think it's not a problem

Would it be possible to create a folder, if the folder does not yet exists?

@xnetcat
Copy link
Member

xnetcat commented Feb 21, 2021

Would it be possible to create a folder, if the folder does not yet exist?

Yeah like that

if not os.path.isdir(arguments.path):
    os.makedirs(arguments.path)
    print("Created download folder")

@xnetcat
Copy link
Member

xnetcat commented Feb 21, 2021

Also, maybe we should come back to the starting path after finishing the download

@aklajnert
Copy link
Contributor Author

When I specify a folder without permission, I get a PermissionError with traceback, but since it's short and clear to understand what went wrong, I think it's not a problem

Good to know, I'll see what I can do there.

Would it be possible to create a folder, if the folder does not yet exists?

I think it would make sense. Not sure, however, if we should accept any path and use mkdir -p equivalent to potentially create multiple levels, or create only one level and raise an error if there is a need to create more. The first option could make some mess if a user forgets a slash in the beginning.

Also, maybe we should come back to the starting path after finishing the download

I don't see a reason to do that. The chdir() doesn't change workdir for the shell where the process was executed.

@xnetcat
Copy link
Member

xnetcat commented Feb 22, 2021

I don't see a reason to do that. The chdir() doesn't change workdir for the shell where the process was executed.

Oh ok my bad

@Silverarmor
Copy link
Member

When I specify a folder without permission, I get a PermissionError with traceback, but since it's short and clear to understand what went wrong, I think it's not a problem

Good to know, I'll see what I can do there.

@aklajnert Do you want to do anything or is this ready to merge?

@aklajnert
Copy link
Contributor Author

@Silverarmor - I'm considering @xnetcat suggestion about creating the output directory if it doesn't exist. I'm not really sure if that's a good idea at all, and if I should create multiple nested directories or limit to one only.

@Silverarmor
Copy link
Member

@aklajnert think we can sneak this into v3.4.0 ?

@aklajnert
Copy link
Contributor Author

@Silverarmor - Yeah, I guess we can merge it as is, we'll change the output directory behavior in case of feedback,

@Silverarmor Silverarmor merged commit 469c20f into spotDL:dev Mar 15, 2021
@Silverarmor
Copy link
Member

@aklajnert @MikhailZex what happened to these changes 🤔

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

Successfully merging this pull request may close these issues.

None yet

5 participants