From 36db651dfa05554d591c1dac6f6de0b7d1791148 Mon Sep 17 00:00:00 2001 From: Lars Noack Date: Fri, 10 May 2024 15:25:11 +0200 Subject: [PATCH] fix: cleaning the song name deleted the song if the song name was the same as the artist name --- music_kraken/utils/string_processing.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/music_kraken/utils/string_processing.py b/music_kraken/utils/string_processing.py index 22ae63e..b76e3fc 100644 --- a/music_kraken/utils/string_processing.py +++ b/music_kraken/utils/string_processing.py @@ -116,10 +116,13 @@ def clean_song_title(raw_song_title: str, artist_name: Optional[str] = None) -> # Remove artist from the start of the title if raw_song_title.lower().startswith(artist_name.lower()): - raw_song_title = raw_song_title[len(artist_name):].strip() - if raw_song_title.startswith("-"): - raw_song_title = raw_song_title[1:].strip() + possible_new_name = raw_song_title[len(artist_name):].strip() + + for char in ("-", "–", ":", "|"): + if possible_new_name.startswith(char): + raw_song_title = possible_new_name[1:].strip() + break return raw_song_title.strip()