mirror of
https://github.com/beetbox/beets.git
synced 2026-01-10 18:07:00 +01:00
Merge pull request #4549 from Bootjewolf/remixerField
Added remixer field
This commit is contained in:
commit
dcba529827
4 changed files with 46 additions and 2 deletions
|
|
@ -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
|
||||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -109,8 +109,8 @@ class MBAlbumInfoTest(_common.TestCase):
|
|||
})
|
||||
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,
|
||||
|
|
@ -128,6 +128,22 @@ class MBAlbumInfoTest(_common.TestCase):
|
|||
'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:
|
||||
|
|
@ -339,6 +355,12 @@ class MBAlbumInfoTest(_common.TestCase):
|
|||
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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue