This commit is contained in:
Hellow 2023-04-18 22:39:19 +02:00
parent a56ccc463d
commit 385edc7087
2 changed files with 19 additions and 9 deletions

View File

@ -13,4 +13,5 @@ setuptools~=60.2.0
tqdm~=4.65.0 tqdm~=4.65.0
peewee~=3.15.4 peewee~=3.15.4
ffmpeg-python~=0.2.0 ffmpeg-python~=0.2.0
platformdirs~=3.2.0 platformdirs~=3.2.0
transliterate~=1.10.2

View File

@ -1,22 +1,31 @@
from transliterate.exceptions import LanguageDetectionError
from transliterate import translit
def unify(string: str) -> str: def unify(string: str) -> str:
""" """
returns an unified str, to make comparosons easy. returns a unified str, to make comparisons easy.
an unified string has following attributes: a unified string has the following attributes:
- is lowercase - is lowercase
""" """
try:
string = translit(string, reversed=True)
except LanguageDetectionError:
pass
return string.lower() return string.lower()
def fit_to_file_system(string: str) -> str: def fit_to_file_system(string: str) -> str:
string = string.strip() string = string.strip()
while string[0] == ".": while string[0] == ".":
if len(string) == 0: if len(string) == 0:
return string return string
string = string[1:] string = string[1:]
string = string.replace("/", "|").replace("\\", "|") string = string.replace("/", "|").replace("\\", "|")
return string return string