add attach playlist feature
This commit is contained in:
parent
aeaef11341
commit
1fc5dc2bf8
3
NOTES.md
3
NOTES.md
|
@ -47,7 +47,7 @@
|
||||||
- Playlist browser
|
- Playlist browser
|
||||||
- [x] Show current playlists
|
- [x] Show current playlists
|
||||||
- [x] `Replace` current queue with playlist button
|
- [x] `Replace` current queue with playlist button
|
||||||
- [ ] `Attach` playlist to current queue button
|
- [x] `Attach` playlist to current queue button
|
||||||
- [ ] `Save` current queue as playlist button
|
- [ ] `Save` current queue as playlist button
|
||||||
- [x] Show dialog
|
- [x] Show dialog
|
||||||
- [ ] `Delete` selected playlist button
|
- [ ] `Delete` selected playlist button
|
||||||
|
@ -78,6 +78,7 @@
|
||||||
- [x] GET `/api/queue/:song_id/delete`
|
- [x] GET `/api/queue/:song_id/delete`
|
||||||
- [x] GET `/api/queue/:song_id/move/:position`
|
- [x] GET `/api/queue/:song_id/move/:position`
|
||||||
- [x] GET `/api/queue/replace/:playlist_name`
|
- [x] GET `/api/queue/replace/:playlist_name`
|
||||||
|
- [x] GET `/api/queue/attach/:playlist_name`
|
||||||
- [ ] `/api/list_database/:path`
|
- [ ] `/api/list_database/:path`
|
||||||
- [x] GET `/api/playlists`
|
- [x] GET `/api/playlists`
|
||||||
- [x] GET `/api/playlists/:name`
|
- [x] GET `/api/playlists/:name`
|
||||||
|
|
19
mpd.go
19
mpd.go
|
@ -335,3 +335,22 @@ func replaceQueue(c echo.Context) error {
|
||||||
|
|
||||||
return c.JSON(http.StatusOK, "")
|
return c.JSON(http.StatusOK, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func attachPlaylist(c echo.Context) error {
|
||||||
|
// Connect to MPD server
|
||||||
|
conn, err := mpd.Dial("tcp", "localhost:6600")
|
||||||
|
if err != nil {
|
||||||
|
c.Logger().Error(err)
|
||||||
|
}
|
||||||
|
defer conn.Close()
|
||||||
|
|
||||||
|
name := c.Param("playlist_name")
|
||||||
|
|
||||||
|
err = conn.PlaylistLoad(name, -1, -1)
|
||||||
|
if err != nil {
|
||||||
|
c.Logger().Error(err)
|
||||||
|
return c.String(http.StatusBadRequest, err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.JSON(http.StatusOK, "")
|
||||||
|
}
|
||||||
|
|
|
@ -92,6 +92,7 @@ func main() {
|
||||||
g.GET("/queue/:song_id/delete", deleteTrackFromQueue)
|
g.GET("/queue/:song_id/delete", deleteTrackFromQueue)
|
||||||
g.GET("/queue/:song_id/move/:position", moveTrackInQueue)
|
g.GET("/queue/:song_id/move/:position", moveTrackInQueue)
|
||||||
g.GET("/queue/replace/:playlist_name", replaceQueue)
|
g.GET("/queue/replace/:playlist_name", replaceQueue)
|
||||||
|
g.GET("/queue/attach/:playlist_name", attachPlaylist)
|
||||||
|
|
||||||
g.GET("/playlists", listPlaylists)
|
g.GET("/playlists", listPlaylists)
|
||||||
g.GET("/playlists/:name", listPlaylist)
|
g.GET("/playlists/:name", listPlaylist)
|
||||||
|
|
|
@ -127,7 +127,7 @@ control_replace_playlist.addEventListener("click", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
control_attach_playlist.addEventListener("click", () => {
|
control_attach_playlist.addEventListener("click", () => {
|
||||||
fetch(`${API_URL}/`).then(async r => {
|
fetch(`${API_URL}/queue/attach/${control_playlist_list.value}`).then(async r => {
|
||||||
if (r.status !== 200) {
|
if (r.status !== 200) {
|
||||||
console.error(`API returned ${r.status}: ${r.statusText}`);
|
console.error(`API returned ${r.status}: ${r.statusText}`);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue