diff --git a/beetsplug/discogs.py b/beetsplug/discogs.py index f22ea2274..caefbe64a 100644 --- a/beetsplug/discogs.py +++ b/beetsplug/discogs.py @@ -652,6 +652,7 @@ class DiscogsPlugin(MetadataSourcePlugin): ) artist = self.strip_disambiguation(artist) length = self.get_track_length(track["duration"]) + featured = map(lambda artist: artist["name"] if artist["role"].find("Featuring") else "", track.get("extraartists", [])) return TrackInfo( title=title, track_id=track_id, diff --git a/test/plugins/test_discogs.py b/test/plugins/test_discogs.py index 92301380e..84573d337 100644 --- a/test/plugins/test_discogs.py +++ b/test/plugins/test_discogs.py @@ -451,6 +451,63 @@ class DGAlbumInfoTest(BeetsTestCase): assert d.tracks[0].artist == "TEST ARTIST (5)" assert d.label == "LABEL NAME (5)" +@pytest.mark.parametrize("track, expected_artist", + [({ + "type_": "track", + "title": "track", + "position": "1", + "duration": "5:00", + "extraartists": [{ + "name": "MUSICIAN", + "role": "Featuring", + }] + }, + "ARTIST feat. MUSICIAN" + ), + ({ + "type_": "track", + "title": "track", + "position": "1", + "duration": "5:00", + "extraartists": [{ + "name": "PERFORMER", + "role": "Other Role, Featuring", + }, { + "name": "MUSICIAN", + "role": "Featuring", + }] + }, + "ARTIST feat. PERFORMER & MUSICIAN" + ), + ({ + "type_": "track", + "title": "track", + "position": "1", + "duration": "5:00", + "artist": "NEW ARTIST", + "extraartists": [{ + "name": "SOLIST", + "role": "Featuring", + }, { + "name": "PERFORMER", + "role": "Other Role, Featuring", + }, { + "name": "RANDOM", + "role": "Written-By", + }, { + "name": "MUSICIAN", + "role": "Featuring", + }] + }, + "NEW ARTIST feat. SOLIST, PERFORMER & MUSICIAN" + )]) +@patch("beetsplug.discogs.DiscogsPlugin.setup", Mock()) +def test_parse_featured_artists(track, expected_artist): + """ Tests the plugins ability to parse a featured artist. + Initial check with one featured artist, two featured artists, + and three. Ignores artists that are not listed as featured.""" + t = DiscogsPlugin().get_track_info(track, 1, 1) + assert t.artist == expected_artist @pytest.mark.parametrize( "formats, expected_media, expected_albumtype",