From 4c2d696ee641af00e826d18f14fd6a0d591998bd Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Sun, 19 Jul 2020 10:41:23 -0500 Subject: [PATCH] Always use safe filenames for downloads --- changes.md | 4 +++- src/utils.py | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/changes.md b/changes.md index 7b49a68..3091308 100644 --- a/changes.md +++ b/changes.md @@ -2,12 +2,14 @@ ## Version 0.7 +* Application improvements: + * MusicDL no longer adds invalid characters when attempting to download a file. * Tidal: * Added a new search mode for the service to retrieve the top rated tracks of a provided artist. The sintax is top://artist. * In the settings dialog, you can control wether Albums, compilations and singles will be added when searching by artist (by using artist://...). * When searching by artists, results that belong to an album will be numbered. * Downloads will be tagged with title, album, artist and track number provided by tidal. - * It is possible to download an original version in high and low quality. Before, those versions were encoded to mp3 from an m4a file. Now the M4a file can be retrieved by ticking the checkbox in the tidal settings page. + * It is possible to download an original version in high and low quality. Before, those versions were encoded to mp3 from an m4a file. Now the M4a file can be retrieved by using the checkbox in the tidal settings page. * YouTube: * Fixed search algorithm for Youtube videos. * Updated Youtube-Dl to version 2020.6.16.1 diff --git a/src/utils.py b/src/utils.py index ce04ff1..2beacd8 100644 --- a/src/utils.py +++ b/src/utils.py @@ -102,4 +102,8 @@ def apply_metadata(local_filename, metadata): audio["\xa9nam"] = metadata["title"] audio["\xa9alb"] = metadata["album"] audio["\xa9ART"] = metadata["artist"] - audio.save() \ No newline at end of file + audio.save() + +def safe_filename(filename): + allowed_symbols = ["_", ".", ",", "-", "(", ")"] + return "".join([c for c in filename if c.isalpha() or c.isdigit() or c==' ' or c in allowed_symbols]).rstrip() \ No newline at end of file