Spaces:
Running
on
Zero
Running
on
Zero
fix: problem with function sanitize
Browse files
app.py
CHANGED
@@ -17,10 +17,7 @@ INPUT_FOLDER = "input"
|
|
17 |
download_path = ""
|
18 |
|
19 |
def sanitize_filename(filename):
|
20 |
-
|
21 |
-
formatted_title = match.group(1) if match else filename
|
22 |
-
|
23 |
-
return sanitize_filename(formatted_title.strip())
|
24 |
|
25 |
def delete_input_files(input_dir):
|
26 |
wav_dir = Path(input_dir) / "wav"
|
@@ -33,7 +30,11 @@ def handle_file_upload(file):
|
|
33 |
return None, "No file uploaded"
|
34 |
|
35 |
filename = os.path.basename(file.name)
|
36 |
-
|
|
|
|
|
|
|
|
|
37 |
|
38 |
input_path = os.path.join(INPUT_FOLDER, "wav", f"{formatted_title}.wav")
|
39 |
os.makedirs(os.path.dirname(input_path), exist_ok=True)
|
|
|
17 |
download_path = ""
|
18 |
|
19 |
def sanitize_filename(filename):
|
20 |
+
return re.sub(r'[\\/*?:"<>|]', '_', filename)
|
|
|
|
|
|
|
21 |
|
22 |
def delete_input_files(input_dir):
|
23 |
wav_dir = Path(input_dir) / "wav"
|
|
|
30 |
return None, "No file uploaded"
|
31 |
|
32 |
filename = os.path.basename(file.name)
|
33 |
+
|
34 |
+
match = re.match(r'^(.*? - .*?)(?: \[.*\]|\(.*\))?$', filename)
|
35 |
+
formatted_title = match.group(1) if match else filename
|
36 |
+
|
37 |
+
formatted_title = sanitize_filename(formatted_title.strip())
|
38 |
|
39 |
input_path = os.path.join(INPUT_FOLDER, "wav", f"{formatted_title}.wav")
|
40 |
os.makedirs(os.path.dirname(input_path), exist_ok=True)
|