Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added remixer field #4549

Merged
merged 5 commits into from
Nov 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions beets/autotag/mb.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,19 @@ def _flatten_artist_credit(credit):
)


def _get_related_artist_names(relations, relation_type):
"""Given a list representing the artist relationships extract the names of
the remixers and concatenate them.
"""
related_artists = []

for relation in relations:
if relation['type'] == relation_type:
related_artists.append(relation['artist']['name'])

return ', '.join(related_artists)


def track_info(recording, index=None, medium=None, medium_index=None,
medium_total=None):
"""Translates a MusicBrainz recording result dictionary into a beets
Expand Down Expand Up @@ -231,6 +244,12 @@ def track_info(recording, index=None, medium=None, medium_index=None,
artist = recording['artist-credit'][0]['artist']
info.artist_id = artist['id']

if recording.get('artist-relation-list'):
info.remixer = _get_related_artist_names(
recording['artist-relation-list'],
relation_type='remixer'
)

if recording.get('length'):
info.length = int(recording['length']) / (1000.0)

Expand Down
1 change: 1 addition & 0 deletions beets/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ class Item(LibModel):
'artist': types.STRING,
'artist_sort': types.STRING,
'artist_credit': types.STRING,
'remixer': types.STRING,
'album': types.STRING,
'albumartist': types.STRING,
'albumartist_sort': types.STRING,
Expand Down
2 changes: 2 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Changelog goes here!

New features:

* We now import the remixer field from Musicbrainz into the library.
:bug:`4428`
* :doc:`/plugins/mbsubmit`: Added a new `mbsubmit` command to print track information to be submitted to MusicBrainz after initial import.
:bug:`4455`
* Added `spotify_updated` field to track when the information was last updated.
Expand Down
26 changes: 24 additions & 2 deletions test/test_mb.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ def _make_release(self, date_str='2009', tracks=None, track_length=None,
})
return release

def _make_track(self, title, tr_id, duration, artist=False, video=False,
disambiguation=None):
def _make_track(self, title, tr_id, duration, artist=False,
video=False, disambiguation=None, remixer=False):
track = {
'title': title,
'id': tr_id,
Expand All @@ -128,6 +128,22 @@ def _make_track(self, title, tr_id, duration, artist=False, video=False,
'name': 'RECORDING ARTIST CREDIT',
}
]
if remixer:
track['artist-relation-list'] = [
{
'type': 'remixer',
'type-id': 'RELATION TYPE ID',
'target': 'RECORDING REMIXER ARTIST ID',
'direction': 'RECORDING RELATION DIRECTION',
'artist':
{
'id': 'RECORDING REMIXER ARTIST ID',
'type': 'RECORDING REMIXER ARTIST TYPE',
'name': 'RECORDING REMIXER ARTIST NAME',
'sort-name': 'RECORDING REMIXER ARTIST SORT NAME'
}
}
]
if video:
track['video'] = 'true'
if disambiguation:
Expand Down Expand Up @@ -339,6 +355,12 @@ def test_track_artist_overrides_recording_artist(self):
self.assertEqual(track.artist_sort, 'TRACK ARTIST SORT NAME')
self.assertEqual(track.artist_credit, 'TRACK ARTIST CREDIT')

def test_parse_recording_remixer(self):
tracks = [self._make_track('a', 'b', 1, remixer=True)]
release = self._make_release(None, tracks=tracks)
track = mb.album_info(release).tracks[0]
self.assertEqual(track.remixer, 'RECORDING REMIXER ARTIST NAME')

def test_data_source(self):
release = self._make_release()
d = mb.album_info(release)
Expand Down