mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 08:39:17 +01:00
Updates to documentation
This commit is contained in:
parent
0ec6689395
commit
1e677d57c1
3 changed files with 145 additions and 85 deletions
|
|
@ -312,9 +312,10 @@ class DiscogsPlugin(MetadataSourcePlugin):
|
|||
Calls the parent class get_artist method."""
|
||||
artist_data = []
|
||||
for artist in artists:
|
||||
if use_anv and (anv := artist.get("anv", "")):
|
||||
artist["name"] = anv
|
||||
artist_data.append(artist)
|
||||
a = artist.copy()
|
||||
if use_anv and (anv := a.get("anv", "")):
|
||||
a["name"] = anv
|
||||
artist_data.append(a)
|
||||
artist, artist_id = super().get_artist(
|
||||
artist_data, join_key="join")
|
||||
return self.strip_disambiguation(artist), artist_id
|
||||
|
|
@ -659,7 +660,8 @@ class DiscogsPlugin(MetadataSourcePlugin):
|
|||
self, track, index, divisions, album_artist_data
|
||||
):
|
||||
"""Returns a TrackInfo object for a discogs track."""
|
||||
album_artist, album_artist_id, artist_credit = album_artist_data
|
||||
|
||||
artist, artist_id, artist_credit = album_artist_data
|
||||
|
||||
title = track["title"]
|
||||
if self.config["index_tracks"]:
|
||||
|
|
@ -669,18 +671,10 @@ class DiscogsPlugin(MetadataSourcePlugin):
|
|||
track_id = None
|
||||
medium, medium_index, _ = self.get_track_index(track["position"])
|
||||
|
||||
artist = album_artist
|
||||
artist_credit = artist_credit
|
||||
artist_id = album_artist_id
|
||||
|
||||
# If artists are found on the track, we will use those instead
|
||||
if (artists := track.get("artists", [])):
|
||||
artist, artist_id = self.get_artist(artists,
|
||||
self.config["track_artist_anv"]
|
||||
)
|
||||
artist_credit, _ = self.get_artist(artists,
|
||||
self.config["artist_credit_anv"]
|
||||
)
|
||||
artist, artist_id = self.get_artist(artists, self.config["track_artist_anv"])
|
||||
artist_credit, _ = self.get_artist(artists, self.config["artist_credit_anv"])
|
||||
length = self.get_track_length(track["duration"])
|
||||
|
||||
# Add featured artists
|
||||
|
|
@ -690,10 +684,8 @@ class DiscogsPlugin(MetadataSourcePlugin):
|
|||
in extraartists
|
||||
if "Featuring"
|
||||
in artist["role"]]
|
||||
featured, _ = self.get_artist(featured_list,
|
||||
self.config["track_artist_anv"])
|
||||
featured_credit, _ = self.get_artist(featured_list,
|
||||
self.config["artist_credit_anv"])
|
||||
featured, _ = self.get_artist(featured_list, self.config["track_artist_anv"])
|
||||
featured_credit, _ = self.get_artist(featured_list, self.config["artist_credit_anv"])
|
||||
if featured:
|
||||
artist = f"{artist} {self.config['featured_label']} {featured}"
|
||||
artist_credit = f"{artist_credit} {self.config['featured_label']} {featured_credit}"
|
||||
|
|
|
|||
|
|
@ -16,6 +16,15 @@ New features:
|
|||
- :doc:`plugins/discogs`: New config option `strip_disambiguation` to toggle
|
||||
stripping discogs numeric disambiguation on artist and label fields.
|
||||
- :doc:`plugins/discogs` Added support for featured artists.
|
||||
- :doc:`plugins/discogs` New configuration option `featured_label` to change the
|
||||
default string used to join featured artists. The default string is `Feat.`
|
||||
- :doc:`plugins/discogs` Added support for `artist_credit` in Discogs tags
|
||||
- :doc:`plugins/discogs` Added support for Discogs artist name variations.
|
||||
Three new boolean configuration options specify where the variations are written,
|
||||
if at all. `album_artist_anv` writes variations to the album artist tag.
|
||||
`track_artist_anv` writes to a tracks artist field. `artist_credit_anv` writes
|
||||
to the `artist_credit` field on both albums and tracks.
|
||||
|
||||
|
||||
Bug fixes:
|
||||
|
||||
|
|
|
|||
|
|
@ -452,19 +452,21 @@ class DGAlbumInfoTest(BeetsTestCase):
|
|||
assert d.label == "LABEL NAME (5)"
|
||||
config["discogs"]["strip_disambiguation"] = True
|
||||
|
||||
def test_use_anv(self):
|
||||
""" Test using artist name variations. """
|
||||
test_cases = [
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"config_input,expected_output",
|
||||
[
|
||||
({
|
||||
"track_artist_anv": False,
|
||||
"album_artist_anv": False,
|
||||
"artist_credit_anv": False
|
||||
},
|
||||
{
|
||||
"album_artist": "ARTIST NAME & SOLOIST",
|
||||
"album_artist_credit": "ARTIST NAME & SOLOIST",
|
||||
"track_artist": "ARTIST Feat. PERFORMER",
|
||||
"track_artist_credit": "ARTIST Feat. PERFORMER"
|
||||
"track_artist_credit": "ARTIST Feat. PERFORMER",
|
||||
"album_artist": "ARTIST & SOLOIST",
|
||||
"album_artist_credit": "ARTIST & SOLOIST",
|
||||
}),
|
||||
({
|
||||
"track_artist_anv": True,
|
||||
|
|
@ -472,11 +474,37 @@ class DGAlbumInfoTest(BeetsTestCase):
|
|||
"artist_credit_anv": False
|
||||
},
|
||||
{
|
||||
"album_artist": "ARTIST NAME & SOLOIST",
|
||||
"album_artist_credit": "ARTIST NAME & SOLOIST",
|
||||
"track_artist": "ARTY Feat. FORMER",
|
||||
"track_artist_credit": "ARTIST Feat. PERFORMER"
|
||||
})]
|
||||
"track_artist": "VARIATION Feat. VARIATION",
|
||||
"track_artist_credit": "ARTIST Feat. PERFORMER",
|
||||
"album_artist": "ARTIST & SOLOIST",
|
||||
"album_artist_credit": "ARTIST & SOLOIST",
|
||||
}),
|
||||
({
|
||||
"track_artist_anv": True,
|
||||
"album_artist_anv": True,
|
||||
"artist_credit_anv": False
|
||||
},
|
||||
{
|
||||
"track_artist": "VARIATION Feat. VARIATION",
|
||||
"track_artist_credit": "ARTIST Feat. PERFORMER",
|
||||
"album_artist": "VARIATION & VARIATION",
|
||||
"album_artist_credit": "ARTIST & SOLOIST",
|
||||
}),
|
||||
({
|
||||
"track_artist_anv": True,
|
||||
"album_artist_anv": True,
|
||||
"artist_credit_anv": True
|
||||
},
|
||||
{
|
||||
"track_artist": "VARIATION Feat. VARIATION",
|
||||
"track_artist_credit": "VARIATION Feat. VARIATION",
|
||||
"album_artist": "VARIATION & VARIATION",
|
||||
"album_artist_credit": "VARIATION & VARIATION",
|
||||
})
|
||||
])
|
||||
@patch("beetsplug.discogs.DiscogsPlugin.setup", Mock())
|
||||
def test_anv(config_input, expected_output):
|
||||
""" Test using artist name variations. """
|
||||
data = {
|
||||
"id": 123,
|
||||
"uri": "https://www.discogs.com/release/123456-something",
|
||||
|
|
@ -488,19 +516,19 @@ class DGAlbumInfoTest(BeetsTestCase):
|
|||
"artists": [{
|
||||
"name": "ARTIST",
|
||||
"tracks": "",
|
||||
"anv": "ARTY",
|
||||
"anv": "VARIATION",
|
||||
"id": 11146
|
||||
}],
|
||||
"extraartists": [{
|
||||
"name": "PERFORMER",
|
||||
"role": "Featuring",
|
||||
"anv": "FORMER",
|
||||
"anv": "VARIATION",
|
||||
"id": 787
|
||||
}],
|
||||
}],
|
||||
"artists": [
|
||||
{"name": "ARTIST NAME", "anv": "ARTISTIC", "id": 321, "join": "&"},
|
||||
{"name": "SOLOIST", "anv": "SOLO", "id": 445, "join": ""},
|
||||
{"name": "ARTIST (4)", "anv": "VARIATION", "id": 321, "join": "&"},
|
||||
{"name": "SOLOIST", "anv": "VARIATION", "id": 445, "join": ""},
|
||||
],
|
||||
"title": "title",
|
||||
}
|
||||
|
|
@ -509,8 +537,6 @@ class DGAlbumInfoTest(BeetsTestCase):
|
|||
title=data["title"],
|
||||
artists=[Bag(data=d) for d in data["artists"]],
|
||||
)
|
||||
for test_case in test_cases:
|
||||
config_input, expected_output = test_case
|
||||
config["discogs"]["album_artist_anv"] = config_input["album_artist_anv"]
|
||||
config["discogs"]["track_artist_anv"] = config_input["track_artist_anv"]
|
||||
config["discogs"]["artist_credit_anv"] = config_input["artist_credit_anv"]
|
||||
|
|
@ -520,6 +546,39 @@ class DGAlbumInfoTest(BeetsTestCase):
|
|||
assert r.tracks[0].artist == expected_output["track_artist"]
|
||||
assert r.tracks[0].artist_credit == expected_output["track_artist_credit"]
|
||||
|
||||
@patch("beetsplug.discogs.DiscogsPlugin.setup", Mock())
|
||||
def test_anv_album_artist():
|
||||
""" Test using artist name variations when the album artist
|
||||
is the same as the track artist, but only the track artist
|
||||
should use the artist name variation."""
|
||||
data = {
|
||||
"id": 123,
|
||||
"uri": "https://www.discogs.com/release/123456-something",
|
||||
"tracklist": [{
|
||||
"title": "track",
|
||||
"position": "A",
|
||||
"type_": "track",
|
||||
"duration": "5:44",
|
||||
}],
|
||||
"artists": [
|
||||
{"name": "ARTIST (4)", "anv": "VARIATION", "id": 321},
|
||||
],
|
||||
"title": "title",
|
||||
}
|
||||
release = Bag(
|
||||
data=data,
|
||||
title=data["title"],
|
||||
artists=[Bag(data=d) for d in data["artists"]],
|
||||
)
|
||||
config["discogs"]["album_artist_anv"] = False
|
||||
config["discogs"]["track_artist_anv"] = True
|
||||
config["discogs"]["artist_credit_anv"] = False
|
||||
r = DiscogsPlugin().get_album_info(release)
|
||||
assert r.artist == "ARTIST"
|
||||
assert r.artist_credit == "ARTIST"
|
||||
assert r.tracks[0].artist == "VARIATION"
|
||||
assert r.tracks[0].artist_credit == "ARTIST"
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"track, expected_artist",
|
||||
[
|
||||
|
|
|
|||
Loading…
Reference in a new issue