mirror of
https://github.com/beetbox/beets.git
synced 2026-02-22 15:22:42 +01:00
Generalise the function to get the names of related artists
This commit is contained in:
parent
ff22d3dc89
commit
1be6c22b44
1 changed files with 10 additions and 7 deletions
|
|
@ -202,17 +202,17 @@ def _flatten_artist_credit(credit):
|
|||
)
|
||||
|
||||
|
||||
def _get_remixer_names(relations):
|
||||
""" Given a list representing the artist relationships extract the names of
|
||||
def _get_related_artist_names(relations, relation_type):
|
||||
"""Given a list representing the artist relationships extract the names of
|
||||
the remixers and concatenate them.
|
||||
"""
|
||||
remixers = []
|
||||
related_artists = []
|
||||
|
||||
for relation in relations:
|
||||
if relation['type'] == 'remixer':
|
||||
remixers.append(relation['artist']['name'])
|
||||
if relation['type'] == relation_type:
|
||||
related_artists.append(relation['artist']['name'])
|
||||
|
||||
return ', '.join(remixers)
|
||||
return ', '.join(related_artists)
|
||||
|
||||
|
||||
def track_info(recording, index=None, medium=None, medium_index=None,
|
||||
|
|
@ -245,7 +245,10 @@ def track_info(recording, index=None, medium=None, medium_index=None,
|
|||
info.artist_id = artist['id']
|
||||
|
||||
if recording.get('artist-relation-list'):
|
||||
info.remixer = _get_remixer_names(recording['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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue