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:
|
for track in tracks:
|
||||||
track.media = media
|
track.media = media
|
||||||
track.medium_total = mediums.count(track.medium)
|
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
|
# Discogs does not have track IDs. Invent our own IDs as proposed
|
||||||
# in #2336.
|
# in #2336.
|
||||||
track.track_id = f"{album_id}-{track.track_alt}"
|
track.track_id = f"{album_id}-{track.track_alt}"
|
||||||
|
|
@ -471,8 +467,9 @@ class DiscogsPlugin(MetadataSourcePlugin):
|
||||||
# divisions.
|
# divisions.
|
||||||
divisions += next_divisions
|
divisions += next_divisions
|
||||||
del next_divisions[:]
|
del next_divisions[:]
|
||||||
track_info = self.get_track_info(track, index, divisions,
|
track_info = self.get_track_info(
|
||||||
album_artist, album_artist_id)
|
track, index, divisions, album_artist, album_artist_id
|
||||||
|
)
|
||||||
track_info.track_alt = track["position"]
|
track_info.track_alt = track["position"]
|
||||||
tracks.append(track_info)
|
tracks.append(track_info)
|
||||||
else:
|
else:
|
||||||
|
|
@ -639,7 +636,9 @@ class DiscogsPlugin(MetadataSourcePlugin):
|
||||||
return text
|
return text
|
||||||
return DISAMBIGUATION_RE.sub("", 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."""
|
"""Returns a TrackInfo object for a discogs track."""
|
||||||
title = track["title"]
|
title = track["title"]
|
||||||
if self.config["index_tracks"]:
|
if self.config["index_tracks"]:
|
||||||
|
|
@ -660,7 +659,10 @@ class DiscogsPlugin(MetadataSourcePlugin):
|
||||||
# Add featured artists
|
# Add featured artists
|
||||||
extraartists = track.get("extraartists", [])
|
extraartists = track.get("extraartists", [])
|
||||||
featured = [
|
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:
|
if featured:
|
||||||
artist = f"{artist} feat. {', '.join(featured)}"
|
artist = f"{artist} feat. {', '.join(featured)}"
|
||||||
return TrackInfo(
|
return TrackInfo(
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,8 @@ Bug fixes:
|
||||||
matching. :bug:`5189`
|
matching. :bug:`5189`
|
||||||
- :doc:`plugins/discogs` Fixed inconsistency in stripping disambiguation from
|
- :doc:`plugins/discogs` Fixed inconsistency in stripping disambiguation from
|
||||||
artists but not labels. :bug:`5366`
|
artists but not labels. :bug:`5366`
|
||||||
|
- :doc:`plugins/discogs` Fixed issue with ignoring featured artists in the
|
||||||
|
extraartists field.
|
||||||
|
|
||||||
For packagers:
|
For packagers:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -451,67 +451,83 @@ class DGAlbumInfoTest(BeetsTestCase):
|
||||||
assert d.tracks[0].artist == "TEST ARTIST (5)"
|
assert d.tracks[0].artist == "TEST ARTIST (5)"
|
||||||
assert d.label == "LABEL NAME (5)"
|
assert d.label == "LABEL NAME (5)"
|
||||||
|
|
||||||
@pytest.mark.parametrize("track, expected_artist",
|
|
||||||
[({
|
@pytest.mark.parametrize(
|
||||||
|
"track, expected_artist",
|
||||||
|
[
|
||||||
|
(
|
||||||
|
{
|
||||||
"type_": "track",
|
"type_": "track",
|
||||||
"title": "track",
|
"title": "track",
|
||||||
"position": "1",
|
"position": "1",
|
||||||
"duration": "5:00",
|
"duration": "5:00",
|
||||||
"extraartists": [{
|
"extraartists": [
|
||||||
|
{
|
||||||
"name": "MUSICIAN",
|
"name": "MUSICIAN",
|
||||||
"role": "Featuring",
|
"role": "Featuring",
|
||||||
}]
|
}
|
||||||
|
],
|
||||||
},
|
},
|
||||||
"ARTIST feat. MUSICIAN"
|
"ARTIST feat. MUSICIAN",
|
||||||
),
|
),
|
||||||
({
|
(
|
||||||
|
{
|
||||||
"type_": "track",
|
"type_": "track",
|
||||||
"title": "track",
|
"title": "track",
|
||||||
"position": "1",
|
"position": "1",
|
||||||
"duration": "5:00",
|
"duration": "5:00",
|
||||||
"extraartists": [{
|
"extraartists": [
|
||||||
|
{
|
||||||
"name": "PERFORMER",
|
"name": "PERFORMER",
|
||||||
"role": "Other Role, Featuring",
|
"role": "Other Role, Featuring",
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
"name": "MUSICIAN",
|
"name": "MUSICIAN",
|
||||||
"role": "Featuring",
|
"role": "Featuring",
|
||||||
}]
|
|
||||||
},
|
},
|
||||||
"ARTIST feat. PERFORMER, MUSICIAN"
|
],
|
||||||
|
},
|
||||||
|
"ARTIST feat. PERFORMER, MUSICIAN",
|
||||||
),
|
),
|
||||||
({
|
(
|
||||||
|
{
|
||||||
"type_": "track",
|
"type_": "track",
|
||||||
"title": "track",
|
"title": "track",
|
||||||
"position": "1",
|
"position": "1",
|
||||||
"duration": "5:00",
|
"duration": "5:00",
|
||||||
"artists": [{
|
"artists": [{"name": "NEW ARTIST", "tracks": "", "id": 11146}],
|
||||||
"name": "NEW ARTIST",
|
"extraartists": [
|
||||||
"tracks": "",
|
{
|
||||||
"id": 11146}],
|
|
||||||
"extraartists": [{
|
|
||||||
"name": "SOLOIST",
|
"name": "SOLOIST",
|
||||||
"role": "Featuring",
|
"role": "Featuring",
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
"name": "PERFORMER",
|
"name": "PERFORMER",
|
||||||
"role": "Other Role, Featuring",
|
"role": "Other Role, Featuring",
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
"name": "RANDOM",
|
"name": "RANDOM",
|
||||||
"role": "Written-By",
|
"role": "Written-By",
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
"name": "MUSICIAN",
|
"name": "MUSICIAN",
|
||||||
"role": "Featuring",
|
"role": "Featuring",
|
||||||
}]
|
|
||||||
},
|
},
|
||||||
"NEW ARTIST feat. SOLOIST, PERFORMER, MUSICIAN"
|
],
|
||||||
)])
|
},
|
||||||
|
"NEW ARTIST feat. SOLOIST, PERFORMER, MUSICIAN",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
@patch("beetsplug.discogs.DiscogsPlugin.setup", Mock())
|
@patch("beetsplug.discogs.DiscogsPlugin.setup", Mock())
|
||||||
def test_parse_featured_artists(track, expected_artist):
|
def test_parse_featured_artists(track, expected_artist):
|
||||||
""" Tests the plugins ability to parse a featured artist.
|
"""Tests the plugins ability to parse a featured artist.
|
||||||
Initial check with one featured artist, two featured artists,
|
Initial check with one featured artist, two featured artists,
|
||||||
and three. Ignores artists that are not listed as featured."""
|
and three. Ignores artists that are not listed as featured."""
|
||||||
t = DiscogsPlugin().get_track_info(track, 1, 1, "ARTIST", 2)
|
t = DiscogsPlugin().get_track_info(track, 1, 1, "ARTIST", 2)
|
||||||
assert t.artist == expected_artist
|
assert t.artist == expected_artist
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"formats, expected_media, expected_albumtype",
|
"formats, expected_media, expected_albumtype",
|
||||||
[
|
[
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue