added a safe-filename function so we will be sure the suggested filename won't break anything in the operating system

This commit is contained in:
2019-10-14 17:25:06 -05:00
parent 9e6e72c0a1
commit 0cdfc253d2
3 changed files with 7 additions and 3 deletions

View File

@@ -90,4 +90,8 @@ def transform_audio_url(url):
url = url.replace("/"+parts[-2], "")
else:
url = url.replace("/"+parts[-3], "")
return url
return url
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()