From 1be6c22b4425987f979dbf04f3f8d8b9455c4bd0 Mon Sep 17 00:00:00 2001 From: Bootjewolf <35065763+Bootjewolf@users.noreply.github.com> Date: Sat, 19 Nov 2022 12:37:51 +0100 Subject: [PATCH] Generalise the function to get the names of related artists --- beets/autotag/mb.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/beets/autotag/mb.py b/beets/autotag/mb.py index 4728b6f7c..5b8d45138 100644 --- a/beets/autotag/mb.py +++ b/beets/autotag/mb.py @@ -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)