From f5acdec2b104b84b0b02000a2bacfc0962a4965f Mon Sep 17 00:00:00 2001 From: Henry Date: Fri, 3 Oct 2025 14:44:22 -0700 Subject: [PATCH] Update configuration format. --- beetsplug/discogs.py | 24 +++++++++++++----------- docs/plugins/discogs.rst | 31 +++++++++++++------------------ test/plugins/test_discogs.py | 12 ++++++------ 3 files changed, 32 insertions(+), 35 deletions(-) diff --git a/beetsplug/discogs.py b/beetsplug/discogs.py index 3c42a5621..ef479f686 100644 --- a/beetsplug/discogs.py +++ b/beetsplug/discogs.py @@ -100,9 +100,11 @@ class DiscogsPlugin(MetadataSourcePlugin): "featured_string": "Feat.", "append_style_genre": False, "strip_disambiguation": True, - "album_artist_anv": False, - "track_artist_anv": False, - "artist_credit_anv": True, + "anv": { + "artist_credit": True, + "artist": False, + "album_artist": False, + }, } ) self.config["apikey"].redact = True @@ -368,9 +370,9 @@ class DiscogsPlugin(MetadataSourcePlugin): ) # Assign ANV to the proper fields for tagging - if not self.config["artist_credit_anv"]: + if not self.config["anv"]["artist_credit"]: artist_credit = album_artist - if self.config["album_artist_anv"]: + if self.config["anv"]["album_artist"]: album_artist = album_artist_anv # Extract information for the optional AlbumInfo fields, if possible. @@ -674,9 +676,9 @@ class DiscogsPlugin(MetadataSourcePlugin): artist, artist_anv, artist_id = album_artist_data artist_credit = artist_anv - if not self.config["artist_credit_anv"]: + if not self.config["anv"]["artist_credit"]: artist_credit = artist - if self.config["track_artist_anv"]: + if self.config["anv"]["artist"]: artist = artist_anv title = track["title"] @@ -690,10 +692,10 @@ class DiscogsPlugin(MetadataSourcePlugin): # If artists are found on the track, we will use those instead if artists := track.get("artists", []): artist, artist_id = self.get_artist_with_anv( - artists, self.config["track_artist_anv"] + artists, self.config["anv"]["artist"] ) artist_credit, _ = self.get_artist_with_anv( - artists, self.config["artist_credit_anv"] + artists, self.config["anv"]["artist_credit"] ) length = self.get_track_length(track["duration"]) @@ -705,10 +707,10 @@ class DiscogsPlugin(MetadataSourcePlugin): if "Featuring" in artist["role"] ] featured, _ = self.get_artist_with_anv( - featured_list, self.config["track_artist_anv"] + featured_list, self.config["anv"]["artist"] ) featured_credit, _ = self.get_artist_with_anv( - featured_list, self.config["artist_credit_anv"] + featured_list, self.config["anv"]["artist_credit"] ) if featured: artist += f" {self.config['featured_string']} {featured}" diff --git a/docs/plugins/discogs.rst b/docs/plugins/discogs.rst index 43b60148f..0d55630c4 100644 --- a/docs/plugins/discogs.rst +++ b/docs/plugins/discogs.rst @@ -96,11 +96,6 @@ whereas with ``index_tracks`` disabled you'd get: This option is useful when importing classical music. -### Handling Artist Name Variations (ANVs) - -An ANV is an alternate way that an artist may be credited on a release. If the -band name changes or is misspelled on different releases. The artist name ac - Other configurations available under ``discogs:`` are: - **append_style_genre**: Appends the Discogs style (if found) to the genre tag. @@ -119,20 +114,20 @@ Other configurations available under ``discogs:`` are: disambiguation in your tags, you can disable it. Default: ``True`` - **featured_string**: Configure the string used for noting featured artists. Useful if you prefer ``Featuring`` or ``ft.``. Default: ``Feat.`` -- **artist_credit_anv**, **track_artist_anv**, **album_artist_anv**: These - configuration option are dedicated to handling Arist Name Variations (ANVs). - Sometimes a release credits artists differently compared to the majority of - their work. For example, "Basement Jaxx" may be credited as "Tha Jaxx" or "The - Basement Jaxx". By default, the Discogs plugin stores ANVs in the - ``artist_credit`` field. You can select any combination of these three to - control where beets writes and stores the variation credit. +- **anv**: These configuration option are dedicated to handling Artist Name + Variations (ANVs). Sometimes a release credits artists differently compared to + the majority of their work. For example, "Basement Jaxx" may be credited as + "Tha Jaxx" or "The Basement Jaxx".You can select any combination of these + config options to control where beets writes and stores the variation credit. + The default, shown below, writes variations to the artist_credit field. - - **artist_credit_anv**: Write ANV to the ``artist_credit`` field. - Default: ``True`` - - **track_artist_anv**: Write ANV to the ``artist`` field. Default: - ``False`` - - **album_artist_anv**: Write ANV to the ``album_artist`` field. Default: - ``False`` +.. code-block:: yaml + + discogs: + anv: + artist_credit: True + artist: False + album_artist: False .. _discogs guidelines: https://support.discogs.com/hc/en-us/articles/360005055373-Database-Guidelines-12-Tracklisting#Index_Tracks_And_Headings diff --git a/test/plugins/test_discogs.py b/test/plugins/test_discogs.py index 40dd30e53..eb65bc588 100644 --- a/test/plugins/test_discogs.py +++ b/test/plugins/test_discogs.py @@ -517,9 +517,9 @@ def test_anv( title=data["title"], artists=[Bag(data=d) for d in data["artists"]], ) - config["discogs"]["album_artist_anv"] = album_artist_anv - config["discogs"]["track_artist_anv"] = track_artist_anv - config["discogs"]["artist_credit_anv"] = artist_credit_anv + config["discogs"]["anv"]["album_artist"] = album_artist_anv + config["discogs"]["anv"]["artist"] = track_artist_anv + config["discogs"]["anv"]["artist_credit"] = artist_credit_anv r = DiscogsPlugin().get_album_info(release) assert r.artist == album_artist assert r.artist_credit == album_artist_credit @@ -553,9 +553,9 @@ def test_anv_album_artist(): 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 + config["discogs"]["anv"]["album_artist"] = False + config["discogs"]["anv"]["artist"] = True + config["discogs"]["anv"]["artist_credit"] = False r = DiscogsPlugin().get_album_info(release) assert r.artist == "ARTIST" assert r.artist_credit == "ARTIST"