fix album versions comparison match too flexible
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Sat, 20 Dec 2025 21:00:05 +0000 (22:00 +0100)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Sat, 20 Dec 2025 21:00:05 +0000 (22:00 +0100)
music_assistant/helpers/compare.py

index 10bc55cf134e3b92a63f24957a35c540d327518b..81b050296d76af987aacb235f30434a9caa2bfb8 100644 (file)
@@ -529,14 +529,16 @@ def loose_compare_strings(base: str, alt: str) -> bool:
     """Compare strings and return True even on partial match."""
     # this is used to display 'versions' of the same track/album
     # where we account for other spelling or some additional wording in the title
-    word_count = len(base.split(" "))
+    if len(base) <= 3 or len(alt) <= 3:
+        return compare_strings(base, alt, True)
+    word_count = len(base.strip().split(" "))
     if word_count == 1 and len(base) < 10:
         return compare_strings(base, alt, False)
     base_comp = create_safe_string(base)
     alt_comp = create_safe_string(alt)
     if base_comp in alt_comp:
         return True
-    return alt_comp in base_comp
+    return base_comp in alt_comp
 
 
 def compare_strings(str1: str, str2: str, strict: bool = True) -> bool: