yyyyyyyan / bandcamper

Bandcamp downloader
MIT License
44 stars 9 forks source link

Sanitize folder/file names for output. #6

Closed colt45rpm closed 1 year ago

colt45rpm commented 1 year ago

Can you clean/sanitize the output folder and file names? Crashes occur when you try to write file or folder names that are not allowed on Linux/Windows.

Maybe use https://pypi.org/project/sanitize-filename/

Iemand005 commented 1 year ago

I was having the same issue, fixed it myself for now by adding file_path /= filename.format(ext=file_ext) file_path = Path(str(file_path).replace("|","")) <-- this line to the downoad path and the path the downloaded file is moved to. with file_path.open("wb") as file:

You can simply add a .replace to the .replace for all the other not allowed characters. This is probably the easiest solution. I may do a pull request for this.