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

Expansion of ~ in -o #1040

Closed
JasonJAyalaP opened this issue Jul 13, 2013 · 8 comments
Closed

Expansion of ~ in -o #1040

JasonJAyalaP opened this issue Jul 13, 2013 · 8 comments
Labels

Comments

@JasonJAyalaP
Copy link

@JasonJAyalaP JasonJAyalaP commented Jul 13, 2013

I may be doing something wrong, but ~ isn't properly expanded to your home folder when used in a template. It instead creates a folder with the name ~.

@jaimeMF
Copy link
Collaborator

@jaimeMF jaimeMF commented Jul 13, 2013

It should be escaped in the template, not in the final filename, don't?. Depending on the video and the template, the filename could start with a ~ or ~username, and would produce an undesired effect.

@JasonJAyalaP
Copy link
Author

@JasonJAyalaP JasonJAyalaP commented Jul 13, 2013

Interesting. Expanding ~ is convenient when writing scripts to share with other people. For example, in the video downloader alfred workflow (which is a group of scripts around youtube-dl), several lines of python code are dedicated just to grabbing the current user home directory.

Not a huge deal, but definitely a gotcha that I tripped over a few times. If there's a clean way to add it and not run into problems with video/usernames with ~, I think it would be helpful.

@jaimeMF
Copy link
Collaborator

@jaimeMF jaimeMF commented Jul 13, 2013

Actually it would need to add just one line of code (it's a function in the standard library), but I don't know if it should be resolved in the ouptut template or in the final filename, I personally think it should be replaced in the template.

@jojopi
Copy link

@jojopi jojopi commented Jul 19, 2013

Not sure what platform you are using, but on *nix, ~ expansion should be done by the shell. Do you not just need to avoid quoting it?

youtube-dl -o ~/yt/'%(title)s.%(ext)s'

Providing duplicate ~ expansion in the application would make it impossible to create files starting with literal '~'.

@jaimeMF
Copy link
Collaborator

@jaimeMF jaimeMF commented Jul 19, 2013

@jojopi Thanks for the hint, you can force creating files with starting '~' if you use a relative path: ./~foo.mp4, this wouldn't be expanded.

@JasonJAyalaP
Copy link
Author

@JasonJAyalaP JasonJAyalaP commented Jul 19, 2013

My little experience and strong bias lead me to argue that a more difficult ~ literal is better than a less intuitive expansion… but maybe that's just my lack of unix skills. The ~/Downloads/'template' thing works great and I have no further objections.

@pdelong42
Copy link

@pdelong42 pdelong42 commented Oct 22, 2013

I know this issue is closed, but I feel there are certain aspects which are still not addressed.

I've had this same problem, but while using -o in my youtube-dl.conf file, and no amount of escaping seems to work (instead of expanding tilde, I get a directory which is literally the tilde character, and it's a pain to remove).

Other possible workarounds I've tried, which also don't work, involve trying to use ${HOME} in the filename template. But it fails to expand - it gets treated literally by youtube-dl - and no amount of escaping helps.

Should I open a new issue for this latter variation of the problem?

@phihag
Copy link
Contributor

@phihag phihag commented Oct 22, 2013

@pdelong42 Expansion works fine for me. Please open a new issue and include the complete output of youtube-dl when called with the -v flag.

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

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.