mirror of
https://github.com/spl0k/supysonic.git
synced 2024-11-09 19:52:16 +00:00
Merge branch 'playlist-export'
This commit is contained in:
commit
9d34270227
@ -7,7 +7,7 @@
|
||||
|
||||
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 ..db import Playlist
|
||||
@ -41,6 +41,29 @@ def playlist_details(uid):
|
||||
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": "attachment; filename={}.m3u".format(playlist.name)
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@frontend.route("/playlist/<uid>", methods=["POST"])
|
||||
def playlist_update(uid):
|
||||
try:
|
||||
|
@ -12,6 +12,6 @@ $(function () {
|
||||
$('[data-toggle="tooltip"]').tooltip()
|
||||
});
|
||||
|
||||
$('#confirm-delete').on('show.bs.modal', function(e) {
|
||||
$('.modal').on('show.bs.modal', function(e) {
|
||||
$(this).find('.btn-ok').attr('href', $(e.relatedTarget).data('href'));
|
||||
});
|
||||
|
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 %}
|
||||
<table class="table table-striped table-hover">
|
||||
<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>
|
||||
<tbody>
|
||||
{% for p in mine %}
|
||||
@ -32,6 +32,8 @@
|
||||
aria-label="Public playlist"></span>{% else %}<span
|
||||
class="glyphicon glyphicon-unchecked"
|
||||
aria-label="Private playlist"></span>{% endif %}</td>
|
||||
<td><button class="btn btn-primary btn-xs" data-href="{{ url_for('frontend.playlist_export', uid = p.id) }}" data-toggle="modal" data-target="#confirm-export" aria-label="Export playlist">
|
||||
<span class="glyphicon glyphicon-arrow-down" aria-hidden="true" data-toggle="tooltip" data-placement="top" title="Export M3U playlist"></span></button></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">
|
||||
<span class="glyphicon glyphicon-remove-circle" aria-hidden="true" data-toggle="tooltip" data-placement="top" title="Delete playlist"></span></button></td>
|
||||
</tr>
|
||||
@ -75,4 +77,24 @@
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div><!-- /.modal -->
|
||||
<div class="modal fade" id="confirm-export" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title">Warning</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>The exported playlist will use the same local paths the server uses itself. This means the playlist will only
|
||||
work on the very same system the Supysonic server is running. If you were to export it from another machine it
|
||||
won't be usable.
|
||||
</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Oh ok. Forget it</button>
|
||||
<a type="button" class="btn btn-primary btn-ok">Got it, export the playlist</a>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div><!-- /.modal -->
|
||||
{% endblock %}
|
||||
|
Loading…
Reference in New Issue
Block a user