This commit is contained in:
Grace Coppola 2025-12-03 11:31:37 -05:00 committed by GitHub
commit fb1d8d738d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 89 additions and 5 deletions

View file

@ -7,7 +7,6 @@ statefile: state.pickle
# --------------- Plugins ---------------
plugins: [musicbrainz]
pluginpath: []
# --------------- Import ---------------

View file

@ -361,6 +361,7 @@ class Album(LibModel):
getters = plugins.album_field_getters()
getters["path"] = Album.item_dir
getters["albumtotal"] = Album._albumtotal
getters["media_types"] = lambda a: a.media_types
return getters
def items(self):

View file

@ -780,10 +780,21 @@ class DiscogsPlugin(MetadataSourcePlugin):
featured_list, self.config["anv"]["artist_credit"]
)
if featured:
artist += f" {self.config['featured_string']} {featured}"
artist_credit += (
f" {self.config['featured_string']} {featured_credit}"
)
featured_string = self.config["featured_string"].as_str()
token = f"{featured_string} {featured}".lower()
token_credit = f"{featured_string} {featured_credit}".lower()
# Only append if this featured artist isn't already present
if token not in artist.lower():
artist += f" {featured_string} {featured}"
if token_credit not in artist_credit.lower():
artist_credit += f" {featured_string} {featured_credit}"
# Previous code
# artist += f" {self.config['featured_string']} {featured}"
# artist_credit += (
# f" {self.config['featured_string']} {featured_credit}"
# )
return IntermediateTrackInfo(
title=title,
track_id=track_id,

View file

@ -27,6 +27,7 @@ New features:
- :doc:`plugins/mbpseudo`: Add a new `mbpseudo` plugin to proactively receive
MusicBrainz pseudo-releases as recommendations during import.
- Added support for Python 3.13.
- Added album-level `$media` field derived from items media metadata.
- :doc:`plugins/titlecase`: Add the `titlecase` plugin to allow users to
resolve differences in metadata source styles.

View file

@ -601,6 +601,30 @@ def test_anv_album_artist():
},
"NEW ARTIST, VOCALIST Feat. SOLOIST, PERFORMER, MUSICIAN",
),
(
{
"type_": "track",
"title": "Infinite Regression",
"position": "6",
"duration": "5:00",
"artists": [
{
"name": "Filteria Feat. Ukiro",
"tracks": "",
"id": 11146,
"join": "",
}
],
"extraartists": [
{
"name": "Ukiro",
"id": 3,
"role": "Featuring",
},
],
},
"Filteria Feat. Ukiro",
),
],
)
@patch("beetsplug.discogs.DiscogsPlugin.setup", Mock())

48
test/test_media_field.py Normal file
View file

@ -0,0 +1,48 @@
# import unittest
# from beets.library import Item, Library
# class MediaFieldTest(unittest.TestCase):
# def setUp(self):
# self.lib = Library(":memory:")
# self.lib.add_album = self.lib.add_album
# def add_album_with_items(self, items_data):
# items = []
# for data in items_data:
# item = Item(**data)
# items.append(item)
# album = self.lib.add_album(items)
# return album
# def test_album_media_field_multiple_types(self):
# items_data = [
# {"title": "Track 1", "artist": "Artist A", "media": "CD"},
# {"title": "Track 2", "artist": "Artist A", "media": "Vinyl"},
# ]
# album = self.add_album_with_items(items_data)
# media = album.media
# assert sorted(media) == ["CD", "Vinyl"]
# def test_album_media_field_single_type(self):
# items_data = [
# {"title": "Track 1", "artist": "Artist A", "media": "CD"},
# {"title": "Track 2", "artist": "Artist A", "media": "CD"},
# ]
# album = self.add_album_with_items(items_data)
# media = album.media
# assert media == ["CD"]
# def test_album_with_no_media(self):
# items_data = [
# {"title": "Track 1", "artist": "Artist A"},
# {"title": "Track 2", "artist": "Artist A"},
# ]
# album = self.add_album_with_items(items_data)
# media = album.media
# assert media == []
# if __name__ == "__main__":
# unittest.main()