mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-22 08:56:17 +00:00
Export playlists to m3u using web interface
This commit is contained in:
parent
be88f5fb78
commit
08329fc8bc
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from flask import flash, redirect, render_template, request, url_for
|
from flask import Response, flash, redirect, render_template, request, url_for
|
||||||
from pony.orm import ObjectNotFound
|
from pony.orm import ObjectNotFound
|
||||||
|
|
||||||
from ..db import Playlist
|
from ..db import Playlist
|
||||||
@ -40,6 +40,27 @@ def playlist_details(uid):
|
|||||||
|
|
||||||
return render_template("playlist.html", playlist=playlist)
|
return render_template("playlist.html", playlist=playlist)
|
||||||
|
|
||||||
|
@frontend.route("/playlist/<uid>/export")
|
||||||
|
def playlist_export(uid):
|
||||||
|
try:
|
||||||
|
uid = uuid.UUID(uid)
|
||||||
|
except ValueError:
|
||||||
|
flash("Invalid playlist id")
|
||||||
|
return redirect(url_for("frontend.playlist_index"))
|
||||||
|
|
||||||
|
try:
|
||||||
|
playlist = Playlist[uid]
|
||||||
|
except ObjectNotFound:
|
||||||
|
flash("Unknown playlist")
|
||||||
|
return redirect(url_for("frontend.playlist_index"))
|
||||||
|
|
||||||
|
return Response(
|
||||||
|
render_template("playlist_export.m3u", playlist=playlist),
|
||||||
|
mimetype="audio/mpegurl",
|
||||||
|
headers={"Content-disposition": f"attachment; filename={playlist.name}.m3u"}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@frontend.route("/playlist/<uid>", methods=["POST"])
|
@frontend.route("/playlist/<uid>", methods=["POST"])
|
||||||
def playlist_update(uid):
|
def playlist_update(uid):
|
||||||
|
12
supysonic/templates/playlist_export.m3u
Normal file
12
supysonic/templates/playlist_export.m3u
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{#-
|
||||||
|
This file is part of Supysonic.
|
||||||
|
Supysonic is a Python implementation of the Subsonic server API.
|
||||||
|
|
||||||
|
Copyright (C) 2013-2018 Alban 'spl0k' Féron
|
||||||
|
2017 Óscar García Amor
|
||||||
|
|
||||||
|
Distributed under terms of the GNU AGPLv3 license.
|
||||||
|
-#}
|
||||||
|
{% for t in playlist.get_tracks() %}
|
||||||
|
{{ t.path }}
|
||||||
|
{% endfor %}
|
@ -21,7 +21,7 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<table class="table table-striped table-hover">
|
<table class="table table-striped table-hover">
|
||||||
<thead>
|
<thead>
|
||||||
<tr><th>Playlist</th><th>Tracks</th><th>Public</th><th></th></tr>
|
<tr><th>Playlist</th><th>Tracks</th><th>Public</th><th>Export</th><th>Delete</th></tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for p in mine %}
|
{% for p in mine %}
|
||||||
@ -32,6 +32,8 @@
|
|||||||
aria-label="Public playlist"></span>{% else %}<span
|
aria-label="Public playlist"></span>{% else %}<span
|
||||||
class="glyphicon glyphicon-unchecked"
|
class="glyphicon glyphicon-unchecked"
|
||||||
aria-label="Private playlist"></span>{% endif %}</td>
|
aria-label="Private playlist"></span>{% endif %}</td>
|
||||||
|
<td><a href="{{ url_for('frontend.playlist_export', uid = p.id) }}">
|
||||||
|
<button class="btn btn-primary btn-xs"><span class="glyphicon glyphicon-arrow-down" title="Export playlist"></span></button></a></td>
|
||||||
<td><button class="btn btn-danger btn-xs" data-href="{{ url_for('frontend.playlist_delete', uid = p.id) }}" data-toggle="modal" data-target="#confirm-delete" aria-label="Delete playlist">
|
<td><button class="btn btn-danger btn-xs" data-href="{{ url_for('frontend.playlist_delete', uid = p.id) }}" data-toggle="modal" data-target="#confirm-delete" aria-label="Delete playlist">
|
||||||
<span class="glyphicon glyphicon-remove-circle" aria-hidden="true" data-toggle="tooltip" data-placement="top" title="Delete playlist"></span></button></td>
|
<span class="glyphicon glyphicon-remove-circle" aria-hidden="true" data-toggle="tooltip" data-placement="top" title="Delete playlist"></span></button></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
Loading…
Reference in New Issue
Block a user