@@ -2536,7 +2536,10 @@ func (s *Server) handlePlayerLoadPlaylist(w http.ResponseWriter, r *http.Request
25362536 return
25372537 }
25382538
2539- if err := streamer .LoadPlaylist (filename ); err != nil {
2539+ // Filename from library browser is absolute now
2540+ playlistName := filepath .Base (filename )
2541+
2542+ if err := streamer .LoadPlaylist (playlistName ); err != nil {
25402543 http .Error (w , err .Error (), http .StatusInternalServerError )
25412544 return
25422545 }
@@ -2546,7 +2549,7 @@ func (s *Server) handlePlayerLoadPlaylist(w http.ResponseWriter, r *http.Request
25462549 for _ , adj := range s .Config .AutoDJs {
25472550 if adj .Mount == mount {
25482551 adj .Playlist = playlistCopy
2549- adj .LastPlaylist = filename
2552+ adj .LastPlaylist = playlistName
25502553 s .Config .SaveConfig ()
25512554 break
25522555 }
@@ -2795,21 +2798,33 @@ func (s *Server) handlePlayerPlaylistAction(w http.ResponseWriter, r *http.Reque
27952798
27962799 if action == "add" {
27972800 fullPath := relPath // Already absolute from frontend now
2798- logrus .Debugf ("AutoDJ %s: Adding song %s to playlist " , mount , fullPath )
2801+ logrus .Infof ("AutoDJ %s: Attempting to add %s " , mount , fullPath )
27992802
28002803 info , err := os .Stat (fullPath )
2801- if err == nil {
2802- if info .IsDir () {
2803- // Add folder recursively
2804- filepath .Walk (fullPath , func (p string , i os.FileInfo , e error ) error {
2805- if e == nil && ! i .IsDir () && strings .ToLower (filepath .Ext (p )) == ".mp3" {
2806- streamer .AddToPlaylist (p )
2807- }
2804+ if err != nil {
2805+ logrus .WithError (err ).Errorf ("AutoDJ %s: Failed to stat path %s" , mount , fullPath )
2806+ http .Error (w , "File not found" , http .StatusNotFound )
2807+ return
2808+ }
2809+
2810+ if info .IsDir () {
2811+ logrus .Infof ("AutoDJ %s: Adding directory %s" , mount , fullPath )
2812+ err := filepath .Walk (fullPath , func (p string , i os.FileInfo , e error ) error {
2813+ if e != nil {
2814+ logrus .WithError (e ).Warnf ("AutoDJ %s: Error walking path %s" , mount , p )
28082815 return nil
2809- })
2810- } else {
2811- streamer .AddToPlaylist (fullPath )
2816+ }
2817+ if ! i .IsDir () && strings .ToLower (filepath .Ext (p )) == ".mp3" {
2818+ streamer .AddToPlaylist (p )
2819+ }
2820+ return nil
2821+ })
2822+ if err != nil {
2823+ logrus .WithError (err ).Errorf ("AutoDJ %s: Walk failed for %s" , mount , fullPath )
28122824 }
2825+ } else {
2826+ logrus .Infof ("AutoDJ %s: Adding single file %s" , mount , fullPath )
2827+ streamer .AddToPlaylist (fullPath )
28132828 }
28142829 } else if action == "remove" {
28152830 var idx int
0 commit comments