From a70820d8a1fc2d16fac2cd89b73a3b86d85ea931 Mon Sep 17 00:00:00 2001 From: Marc Addeo Date: Sun, 28 Dec 2014 20:20:29 -0500 Subject: [PATCH] Fix a bug in ftintitle with the order of album artist There was a bug in the find_feat_part function that would cause it to fail if the album artist was the second part of the featured string. For example, if the Artist field was Alice & Bob, and the Album Artist field was Bob it would return None due to the order. This fixes that and adds test cases to ensure it doesn't return. --- beetsplug/ftintitle.py | 2 +- test/test_ftintitle.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/beetsplug/ftintitle.py b/beetsplug/ftintitle.py index bfeaf734d..d332b0c08 100644 --- a/beetsplug/ftintitle.py +++ b/beetsplug/ftintitle.py @@ -95,7 +95,7 @@ def find_feat_part(artist, albumartist): # featuring artist on the left-hand side. else: lhs, rhs = split_on_feat(albumartist_split[0]) - if rhs: + if lhs: feat_part = lhs return feat_part diff --git a/test/test_ftintitle.py b/test/test_ftintitle.py index cffa3332a..fa51dfc14 100644 --- a/test/test_ftintitle.py +++ b/test/test_ftintitle.py @@ -32,6 +32,8 @@ class FtInTitlePluginTest(unittest.TestCase): {'artist': 'Alice and Bob', 'album_artist': 'Alice', 'feat_part': 'Bob'}, {'artist': 'Alice With Bob', 'album_artist': 'Alice', 'feat_part': 'Bob'}, {'artist': 'Alice defeat Bob', 'album_artist': 'Alice', 'feat_part': None}, + {'artist': 'Alice & Bob', 'album_artist': 'Bob', 'feat_part': 'Alice'}, + {'artist': 'Alice ft. Bob', 'album_artist': 'Bob', 'feat_part': 'Alice'}, ] for test_case in test_cases: