diff --git a/beetsplug/ftintitle.py b/beetsplug/ftintitle.py index d332b0c08..fbeb7bc27 100644 --- a/beetsplug/ftintitle.py +++ b/beetsplug/ftintitle.py @@ -23,12 +23,15 @@ import re log = logging.getLogger('beets') + class ArtistNotFoundException(Exception): def __init__(self, value): self.value = value + def __str__(self): return repr(self.value) + def split_on_feat(artist): """Given an artist string, split the "main" artist from any artist on the right-hand side of a string like "feat". Return the main @@ -100,6 +103,7 @@ def find_feat_part(artist, albumartist): return feat_part + def ft_in_title(item, drop_feat, loglevel=logging.DEBUG): """Look for featured artists in the item's artist fields and move them to the title. diff --git a/test/test_ftintitle.py b/test/test_ftintitle.py index fa51dfc14..249569566 100644 --- a/test/test_ftintitle.py +++ b/test/test_ftintitle.py @@ -25,19 +25,58 @@ class FtInTitlePluginTest(unittest.TestCase): def test_find_feat_part(self): test_cases = [ - {'artist': 'Alice ft. Bob', 'album_artist': 'Alice', 'feat_part': 'Bob'}, - {'artist': 'Alice feat Bob', 'album_artist': 'Alice', 'feat_part': 'Bob'}, - {'artist': 'Alice featuring Bob', 'album_artist': 'Alice', 'feat_part': 'Bob'}, - {'artist': 'Alice & Bob', 'album_artist': 'Alice', 'feat_part': 'Bob'}, - {'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'}, + { + 'artist': 'Alice ft. Bob', + 'album_artist': 'Alice', + 'feat_part': 'Bob' + }, + { + 'artist': 'Alice feat Bob', + 'album_artist': 'Alice', + 'feat_part': 'Bob' + }, + { + 'artist': 'Alice featuring Bob', + 'album_artist': 'Alice', + 'feat_part': 'Bob' + }, + { + 'artist': 'Alice & Bob', + 'album_artist': 'Alice', + 'feat_part': 'Bob' + }, + { + '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: - feat_part = ftintitle.find_feat_part(test_case['artist'], test_case['album_artist']) + feat_part = ftintitle.find_feat_part( + test_case['artist'], + test_case['album_artist'] + ) self.assertEqual(feat_part, test_case['feat_part']) def test_split_on_feat(self):