diff --git a/beets/autotag/hooks.py b/beets/autotag/hooks.py index 06107295a..a3d4bf61b 100644 --- a/beets/autotag/hooks.py +++ b/beets/autotag/hooks.py @@ -70,7 +70,15 @@ def correct_list_fields(input_data: JSONDict) -> JSONDict: def ensure_first_value(single_field: str, list_field: str) -> None: """Ensure the first ``list_field`` item is equal to ``single_field``.""" - single_val, list_val = data.get(single_field), data.get(list_field, []) + single_val, list_val = ( + data.get(single_field) or "", + data.get(list_field, []), + ) + if single_val not in list_val and set(single_val.lower().split()) & set( + map(str.lower, list_val) + ): + return + if single_val: data[list_field] = unique_list([single_val, *list_val]) elif list_val: diff --git a/test/autotag/test_hooks.py b/test/autotag/test_hooks.py index ddaced54e..fc1024057 100644 --- a/test/autotag/test_hooks.py +++ b/test/autotag/test_hooks.py @@ -258,6 +258,10 @@ class TestOverwriteNull: ("1", ["1", "2"], ("1", ["1", "2"])), ("1", ["2", "1"], ("1", ["1", "2"])), ("1", ["2"], ("1", ["1", "2"])), + ("1 ft 2", ["1", "1 ft 2"], ("1 ft 2", ["1 ft 2", "1"])), + ("1 FT 2", ["1", "1 ft 2"], ("1 FT 2", ["1", "1 ft 2"])), + ("a", ["b", "A"], ("a", ["b", "A"])), + ("1 ft 2", ["2", "1"], ("1 ft 2", ["2", "1"])), ], ) def test_correct_list_fields(