Skip to content

Commit

Permalink
examples: handle multiple artists in the credits
Browse files Browse the repository at this point in the history
There can be multiple artists in the artist-credits that are separated
by a " + ". This is a string, not an artist object in itself.

The library provides "artist-credit-phrase", which is used in the
example.

Signed-off-by: Johannes Dewender <github@JonnyJD.net>
  • Loading branch information
JonnyJD committed May 11, 2012
1 parent 9d33cef commit 8586b56
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions examples/releasesearch.py
Expand Up @@ -21,8 +21,10 @@
def show_release_details(rel):
"""Print some details about a release dictionary to stdout.
"""
artist_names = [c['artist']['name'] for c in rel['artist-credit']]
print("{}, by {}".format(rel['title'], ', '.join(artist_names)))
# "artist-credit-phrase" is a flat string of the credited artists
# joined with " + " or whatever is given by the server.
# You can also work with the "artist-credit" list manually.
print("{}, by {}".format(rel['title'], rel["artist-credit-phrase"]))
if 'date' in rel:
print("Released {} ({})".format(rel['date'], rel['status']))
print("MusicBrainz ID: {}".format(rel['id']))
Expand Down

0 comments on commit 8586b56

Please sign in to comment.