{% extends "template.html" %}
{% block content %}

<div class="mpd-search-results">
  <div class="container">

    {% if path: %}
    <h3>{{ path }}</h3>
    {% endif %}
    <div class="d-flex flex-column mt-3">
      <ul class="list-group mb-3 flex-fill">
        {% for item in results %}
        {% if item.directory and (spotify and item.directory.startswith('spotify:') or not spotify and not item.directory.startswith('spotify:')): %}
        <li href="#" class="list-group-item flex-fill">
          <div class="d-flex w-100">
            <h5 class="mb-1"><a href="{{ url_for('pages.mpd_list', path=item.directory) }}">{{ item.directory }}</a>
            </h5>
          </div>
          <a class="btn btn-primary" href="{{ url_for('api.rfid_write', value='mpd:' + item.directory) }}"><i
              class="bi bi-pencil-square"></i>
            Write to card</a>
          <a class="btn btn-secondary" href="{{ url_for('api.play', uri='mpd:' + item.directory) }}"><i
              class="bi bi-play"></i> Play
            now</a>
          {% endif %}
        </li>
        {% if item.file and not item.file.startswith('.') and (spotify and item.file.startswith('spotify:') or not spotify and not item.file.startswith('spotify:')): %}
        <li href="#" class="list-group-item flex-fill">
          <div class="d-flex w-100">
            <h5 class="mb-1">{{ item.file }}</h5>
          </div>
          <a class="btn btn-primary" href="{{ url_for('api.rfid_write', value='mpd:' + path + '/' + item.file) }}"><i
              class="bi bi-pencil-square"></i>
            Write to card</a>
        </li>
        {% endif %}
        {% endfor %}
      </ul>
    </div>

    {% if not spotify: %}
    <a href="{{ url_for('pages.mpd_list', spotify=true) }}">List Spotify Downloads</a>
    {% endif %}
    {% if spotify: %}
    <a href="{{ url_for('pages.mpd_list') }}">List MPD files</a>
    {% endif %}
  </div>
</div>

{% endblock %}