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

Escape filename characters instead of dropping them. #342

Open
bittaurus opened this issue Jun 25, 2020 · 1 comment
Open

Escape filename characters instead of dropping them. #342

bittaurus opened this issue Jun 25, 2020 · 1 comment

Comments

@bittaurus
Copy link

I noticed you drop filesystem reserved characters from the filename.

Consider that this can cause other problems:

Resulting filename can be empty if all characters are invalid.
Resulting filename can be "special" dependant on the OS, like ".", "..", "CON" in windows, etc.

In linux, the only invalid printable character is '/'.

Also, dropping / will remove things like date delimination in the format:

"11/1/1999" and "1/11/1999" become equal and a collision.

Windows has an infinite number of invalid filenames. For example one composed of only dots and spaces is invalid.

As a baseline for linux, would the best practice be to escape problematic characters and convert / to another character?

@bittaurus
Copy link
Author

bittaurus commented Jun 30, 2020

the following mod to scdl.py replaces invalid characters with '_' instead of dropping them:

in get_filename():

filename = ''.join([(c if c not in invalid_chars else "_") for c in filename])

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

No branches or pull requests

1 participant