add attach playlist feature
This commit is contained in:
		
							parent
							
								
									aeaef11341
								
							
						
					
					
						commit
						1fc5dc2bf8
					
				
					 4 changed files with 23 additions and 2 deletions
				
			
		
							
								
								
									
										3
									
								
								NOTES.md
									
										
									
									
									
								
							
							
						
						
									
										3
									
								
								NOTES.md
									
										
									
									
									
								
							|  | @ -47,7 +47,7 @@ | |||
| - Playlist browser | ||||
|   - [x] Show current playlists | ||||
|   - [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 | ||||
|     - [x] Show dialog | ||||
|   - [ ] `Delete` selected playlist button | ||||
|  | @ -78,6 +78,7 @@ | |||
|   - [x] GET `/api/queue/:song_id/delete` | ||||
|   - [x] GET `/api/queue/:song_id/move/:position` | ||||
|   - [x] GET `/api/queue/replace/:playlist_name` | ||||
|   - [x] GET `/api/queue/attach/:playlist_name` | ||||
|   - [ ] `/api/list_database/:path` | ||||
|   - [x] GET `/api/playlists` | ||||
|   - [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, "") | ||||
| } | ||||
| 
 | ||||
| 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/move/:position", moveTrackInQueue) | ||||
| 	g.GET("/queue/replace/:playlist_name", replaceQueue) | ||||
| 	g.GET("/queue/attach/:playlist_name", attachPlaylist) | ||||
| 
 | ||||
| 	g.GET("/playlists", listPlaylists) | ||||
| 	g.GET("/playlists/:name", listPlaylist) | ||||
|  |  | |||
|  | @ -127,7 +127,7 @@ control_replace_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) { | ||||
|       console.error(`API returned ${r.status}: ${r.statusText}`); | ||||
|     } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue