Skip to content

Commit 5df959e

Browse files
committed
Support generators in MetadataSourcePlugin.get_artist method
1 parent 78055df commit 5df959e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

beets/plugins.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,8 @@ def get_artist(artists, id_key='id', name_key='name', join_key=None):
685685
"""
686686
artist_id = None
687687
artist_string = ""
688+
artists = list(artists) # In case a generator was passed.
689+
total = len(artists)
688690
for idx, artist in enumerate(artists):
689691
if not artist_id:
690692
artist_id = artist[id_key]
@@ -694,7 +696,7 @@ def get_artist(artists, id_key='id', name_key='name', join_key=None):
694696
# Move articles to the front.
695697
name = re.sub(r'^(.*?), (a|an|the)$', r'\2 \1', name, flags=re.I)
696698
# Use a join keyword if requested and available.
697-
if idx < (len(artists) - 1): # Skip joining on last.
699+
if idx < (total - 1): # Skip joining on last.
698700
if join_key and artist.get(join_key, None):
699701
name += " " + artist[join_key] + " "
700702
else:

0 commit comments

Comments
 (0)