mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 08:39:17 +01:00
testing, updated changelog
This commit is contained in:
parent
876c57c8b3
commit
43f2d423fa
3 changed files with 83 additions and 63 deletions
|
|
@ -386,10 +386,6 @@ class DiscogsPlugin(MetadataSourcePlugin):
|
|||
for track in tracks:
|
||||
track.media = media
|
||||
track.medium_total = mediums.count(track.medium)
|
||||
if not track.artist: # get_track_info often fails to find artist
|
||||
track.artist = artist
|
||||
if not track.artist_id:
|
||||
track.artist_id = artist_id
|
||||
# Discogs does not have track IDs. Invent our own IDs as proposed
|
||||
# in #2336.
|
||||
track.track_id = f"{album_id}-{track.track_alt}"
|
||||
|
|
@ -471,8 +467,9 @@ class DiscogsPlugin(MetadataSourcePlugin):
|
|||
# divisions.
|
||||
divisions += next_divisions
|
||||
del next_divisions[:]
|
||||
track_info = self.get_track_info(track, index, divisions,
|
||||
album_artist, album_artist_id)
|
||||
track_info = self.get_track_info(
|
||||
track, index, divisions, album_artist, album_artist_id
|
||||
)
|
||||
track_info.track_alt = track["position"]
|
||||
tracks.append(track_info)
|
||||
else:
|
||||
|
|
@ -639,7 +636,9 @@ class DiscogsPlugin(MetadataSourcePlugin):
|
|||
return text
|
||||
return DISAMBIGUATION_RE.sub("", text)
|
||||
|
||||
def get_track_info(self, track, index, divisions, album_artist, album_artist_id):
|
||||
def get_track_info(
|
||||
self, track, index, divisions, album_artist, album_artist_id
|
||||
):
|
||||
"""Returns a TrackInfo object for a discogs track."""
|
||||
title = track["title"]
|
||||
if self.config["index_tracks"]:
|
||||
|
|
@ -660,7 +659,10 @@ class DiscogsPlugin(MetadataSourcePlugin):
|
|||
# Add featured artists
|
||||
extraartists = track.get("extraartists", [])
|
||||
featured = [
|
||||
artist["name"] for artist in extraartists if artist["role"].find("Featuring") != -1]
|
||||
artist["name"]
|
||||
for artist in extraartists
|
||||
if artist["role"].find("Featuring") != -1
|
||||
]
|
||||
if featured:
|
||||
artist = f"{artist} feat. {', '.join(featured)}"
|
||||
return TrackInfo(
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ Bug fixes:
|
|||
matching. :bug:`5189`
|
||||
- :doc:`plugins/discogs` Fixed inconsistency in stripping disambiguation from
|
||||
artists but not labels. :bug:`5366`
|
||||
- :doc:`plugins/discogs` Fixed issue with ignoring featured artists in the
|
||||
extraartists field.
|
||||
|
||||
For packagers:
|
||||
|
||||
|
|
|
|||
|
|
@ -451,67 +451,83 @@ 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",
|
||||
"artists": [{
|
||||
"name": "NEW ARTIST",
|
||||
"tracks": "",
|
||||
"id": 11146}],
|
||||
"extraartists": [{
|
||||
"name": "SOLOIST",
|
||||
"role": "Featuring",
|
||||
}, {
|
||||
"name": "PERFORMER",
|
||||
"role": "Other Role, Featuring",
|
||||
}, {
|
||||
"name": "RANDOM",
|
||||
"role": "Written-By",
|
||||
}, {
|
||||
"name": "MUSICIAN",
|
||||
"role": "Featuring",
|
||||
}]
|
||||
},
|
||||
"NEW ARTIST feat. SOLOIST, PERFORMER, MUSICIAN"
|
||||
)])
|
||||
|
||||
@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",
|
||||
"artists": [{"name": "NEW ARTIST", "tracks": "", "id": 11146}],
|
||||
"extraartists": [
|
||||
{
|
||||
"name": "SOLOIST",
|
||||
"role": "Featuring",
|
||||
},
|
||||
{
|
||||
"name": "PERFORMER",
|
||||
"role": "Other Role, Featuring",
|
||||
},
|
||||
{
|
||||
"name": "RANDOM",
|
||||
"role": "Written-By",
|
||||
},
|
||||
{
|
||||
"name": "MUSICIAN",
|
||||
"role": "Featuring",
|
||||
},
|
||||
],
|
||||
},
|
||||
"NEW ARTIST feat. SOLOIST, 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,
|
||||
"""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, "ARTIST", 2)
|
||||
assert t.artist == expected_artist
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"formats, expected_media, expected_albumtype",
|
||||
[
|
||||
|
|
|
|||
Loading…
Reference in a new issue