From 3c5bbc19af167a34e7e9067ba04432e271367e92 Mon Sep 17 00:00:00 2001 From: Lars Noack Date: Fri, 19 Apr 2024 12:04:13 +0200 Subject: [PATCH] feat: some slight performance improvements --- music_kraken/utils/string_processing.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/music_kraken/utils/string_processing.py b/music_kraken/utils/string_processing.py index b591604..00b6024 100644 --- a/music_kraken/utils/string_processing.py +++ b/music_kraken/utils/string_processing.py @@ -56,6 +56,7 @@ def fit_to_file_system(string: Union[str, Path]) -> Union[str, Path]: return fit_string(string) +@lru_cache(maxsize=128) def clean_song_title(raw_song_title: str, artist_name: Optional[str] = None) -> str: """ This function cleans common naming "conventions" for non clean song titles, like the title of youtube videos @@ -76,6 +77,9 @@ def clean_song_title(raw_song_title: str, artist_name: Optional[str] = None) -> # remove brackets and their content if they contain disallowed substrings for open_bracket, close_bracket in zip(OPEN_BRACKETS, CLOSE_BRACKETS): + if open_bracket not in raw_song_title or close_bracket not in raw_song_title: + continue + start = 0 while True: