fix: previously introduced crashed

This commit is contained in:
Hellow 2023-10-13 00:11:58 +02:00
parent b4cc0955fd
commit 424357bb65

View File

@ -1,4 +1,5 @@
from typing import Tuple
from typing import Tuple, Union
from pathlib import Path
from transliterate.exceptions import LanguageDetectionError
from transliterate import translit
@ -25,24 +26,27 @@ def unify(string: str) -> str:
return string.lower()
def fit_to_file_system(string: str) -> str:
def fit_to_file_system(string: Union[str, Path]) -> Union[str, Path]:
def fit_string(string: str) -> str:
if string == "/":
return "/"
string = string.strip()
string = string.strip(".")
"""
while string[0] == ".":
if len(string) == 0:
return string
string = string[1:]
"""
string = string.replace("/", "_").replace("\\", "_")
string = sanitize_filename(string)
return string
if isinstance(string, Path):
return Path(*(fit_string(part) for part in string.parts))
else:
return fit_string(string)
def clean_song_title(raw_song_title: str, artist_name: str) -> str:
"""