From f1794e87098c435b07006158504ad7b5cbed1bad Mon Sep 17 00:00:00 2001 From: J0J0 Todos Date: Thu, 29 Dec 2022 18:04:57 +0100 Subject: [PATCH] Support generators in MetadataSourcePlugin.get_artist method --- beets/plugins.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/beets/plugins.py b/beets/plugins.py index fe8bb532a..c14d7b423 100644 --- a/beets/plugins.py +++ b/beets/plugins.py @@ -685,6 +685,8 @@ class MetadataSourcePlugin(metaclass=abc.ABCMeta): """ artist_id = None artist_string = "" + artists = list(artists) # In case a generator was passed. + total = len(artists) for idx, artist in enumerate(artists): if not artist_id: artist_id = artist[id_key] @@ -694,7 +696,7 @@ class MetadataSourcePlugin(metaclass=abc.ABCMeta): # Move articles to the front. name = re.sub(r'^(.*?), (a|an|the)$', r'\2 \1', name, flags=re.I) # Use a join keyword if requested and available. - if idx < (len(artists) - 1): # Skip joining on last. + if idx < (total - 1): # Skip joining on last. if join_key and artist.get(join_key, None): name += f" {artist[join_key]} " else: