{% extends 'base.html' %} {% from 'macros.html' import display_pagination with context %} {% block title %}{{ _('Spotify album mapping') }} - CritiqueBrainz{% endblock %} {% block content %}

{{ _('Spotify album mapping') }}

{% if release_group['first-release-date'] is defined %} {% set album = '"%s" (%s)'|safe % (release_group.title, release_group['first-release-date'][:4]) %} {% elif release_group['first-release-year'] is defined %} {% set album = '"%s" (%s)'|safe % (release_group.title, release_group['first-release-year']) %} {% else %} {% set album = '"%s"' % release_group.title %} {% endif %} {{ _('Please select the album %(album)s by %(artist)s, or provide a link to Spotify below.', album=album, artist=release_group['artist-credit-phrase']) }}

{% if search_results %}
{% for item in search_results %}
{{ item.name }}
by {{ artists(item) }}
{{ release_date_string(item) }} {{ item.album_type }}
{{ _('Listen on Spotify') }}
{% endfor %}
{{ display_pagination(page, count, limit, 'mapping.spotify_add', {'release_group_id':release_group.mbid}) }} {% else %}

{{ _('No similar albums found') }}

{% endif %}

{{ _('If you can’t find the right album in search results, you can paste a Spotify link there:') }}


{{ _('A Spotify link should look like %(uri_example)s or %(link_example)s.', uri_example = 'spotify:album:3CCO9PhQXCQXUWjcEfys9B' | safe, link_example = 'https://play.spotify.com/album/3CCO9PhQXCQXUWjcEfys9B' | safe) }}


{{ _('It’s fine if you can’t find the right album. It might not be available on Spotify yet.') }} {{ _('You can go back to the release group page.', link=url_for('release_group.entity', id=release_group.mbid)) }}

{% endblock %} {% block scripts %} {{ super() }} {% endblock %} {% macro artists(album) -%} {% if album.artists|length == 0 or album.artists[0].name != 'Various Artists' %} {%- for artist in album.artists %} {{ artist.name }} {% if not loop.last %} {{ ', ' }} {% endif %} {%- endfor %} {% else %} {% set added_artists=[] %} {% for track in album.tracks['items'] %} {% for artist in track.artists %} {% if artist.name not in added_artists and artist.name != 'Various Artists'%} {% do added_artists.append(artist.name)%} {% endif %} {% endfor %} {% endfor %} {% for artist_name in added_artists %} {{ artist_name }} {% if not loop.last %} {{ ', ' }} {% endif %} {% endfor %} {% endif %} {%- endmacro %} {% macro release_date_string(album) -%} {% if album.release_date is defined %} {{ album.release_date.split('-')[0] }} {% endif %} {%- endmacro %}