DownOnSpot
DownOnSpot copied to clipboard
sanitize_filename used incorrectly
Describe the bug Using sanitize_filename::sanitize with default options possibly truncates some parts of the track filename. However, the final assembled filename is not truncated at all, which may exceed file name limits of some filesystems (e.g. utf 8 - Is the Ext3 filename limited to 255 symbols or 255 bytes? - Server Fault
To Reproduce Steps to reproduce the behavior:
-
Set the
filename_template
to%0track% %artist% - %title% - %title% - %title% - %title%
"filename_template": "%0track% %artist% - %title% - %title% - %title% - %title%",
-
Run
down_on_spot spotify:track:1JTU0397lTr8kM4ghhG0Cf
-
Observe
IO: InvalidFilename File name too long (os error 36)
Settings successfully loaded. Continuing with spotify account: [email protected] Login succeeded. Preparing... | Track 1 - Die Dritte Macht - Perry Rhodan - Silber Edition 1 Elapsed second(s): 0 IO: InvalidFilename File name too long (os error 36) | Track 1 - Die Dritte Macht - Perry Rhodan - Silber Edition 1 Finished download(s) in 4 second(s).
Expected behavior Applying sanitize to each component of the assembled track title path (including the extension!) instead of arbitrary tags gives a better result.
For example, in Python the applicable algorithm would be (sorry, I don't speak Rust):
path = "/".join((sanitize(_p) for _p in path.split("/")))
Desktop (please complete the following information):
- OS: GNU/Linux Ubuntu 10.04