nathom / streamrip

A scriptable music downloader for Qobuz, Tidal, SoundCloud, and Deezer
GNU General Public License v3.0
2.4k stars 211 forks source link

Added path string validation #574

Closed AlexKalopsia closed 6 months ago

AlexKalopsia commented 6 months ago

I ran into a couple of situations where streamrip would fail to process the data if the album or the artist included special characters (even one case where the record name had a random trailing empty space).

The format I use is folder_format = "{albumartist}/{year} - {title}", hence an album like 2024 - Cool Name (note trailing space) or 2024 - Hot / Cold (special char) will fail the path creation, since it will try and create C:/2024 - Cool Name /__artwork (not valid, at least on Windows), or could try and split the path like C:/2024 - Hot / Cold/__artwork, and also fail in the process.

The PR just adds a simple string validation to prevent any of those invalid characters, as well as trailing spaces.

Example record with special character Example record with trailing space

nathom commented 6 months ago

Thanks for the fix. We have a similar function implemented here

https://github.com/nathom/streamrip/blob/3787bbb48ed5a7ec5aebc990989a429ad377ca09/streamrip/filepath_utils.py#L8-L13

Can you use that instead?