flash_and_log(f"Deleted playlist {plist_data['name']}", "success")
return redirect(request.referrer)
-@app.post("/append-to-playlist/<int:playlistid>")
-def append_to_playlist(playlistid):
+@app.post("/append-to-playlist")
+def append_to_playlist():
if not "userid" in session:
abort(401)
# Make sure playlist exists
+ try:
+ playlistid = int(request.form["playlistid"])
+ except ValueError:
+ abort(400)
+
plist_data = query_db("select * from playlists where playlistid = ?", args=[playlistid])
if not plist_data:
abort(404)
if session["userid"] != plist_data["userid"]:
abort(401)
- songid = request.args["songid"]
+ songid = request.form["songid"]
# Make sure song exists
song_data = query_db("select * from songs where songid = ?", args=[songid])
</div>
{% endfor %}
+ {% if playlists -%}
<!-- Playlist selector, shown when Add to Playlist is clicked -->
<div class="playlist-selector" hidden>
- <!-- TODO -->
+ <form>
+ <input type="hidden" name="songid" value="-1" id="playlist-selector-songid"/>
+ <select name="playlistid">
+ {% for plist in playlists -%}
+ <option value="{{ plist.playlistid }}">{{ plist.name }}</option>
+ {%- endfor %}
+ </select>
+ <input type="submit" value="submit" />
+ </form>
</div>
+ {%- endif %}
</div>
<script>
return false;
}
+{% if playlists %}
var m_addToPlaylistSongid = null;
function showPlaylistSelector(event, songid) {
m_addToPlaylistSongid = songid;
var songList = event.target.closest(".song-list");
var playlistSelector = songList.querySelector(".playlist-selector");
playlistSelector.hidden = false;
+ var songidInput = playlistSelector.querySelector("#playlist-selector-songid")
+ songInput.value = songid
return false;
}
+{% endif $}
</script>
NOW
-- Apply user colors to songs in lists outside profile
+- Playlists:
+ - Create
+ - Play
+ - Remove song
+ - Reorder songs
+ - Delete
+ - Pin to profile
+ - Albums?
+- Show upload date in song list
SOON
- Player minimize button
- Remove songs
- Reorder songs
- Automatically use songs on page when queue ends
-- Playlists:
- - Create
- - Play
- - Remove song
- - Reorder songs
- - Delete
- - Pin to profile
- - Albums?
LATER
- Show song info for song in player (description, tags)