@@ -11,6 +11,7 @@ import (
1111 "time"
1212
1313 "github.com/DatanoiseTV/tinyice/config"
14+ "github.com/dhowden/tag"
1415 "github.com/hajimehoshi/go-mp3"
1516 "github.com/sirupsen/logrus"
1617)
@@ -352,13 +353,25 @@ func (sm *StreamerManager) streamFile(ctx context.Context, s *Streamer, path str
352353 }
353354 defer f .Close ()
354355
356+ // Extract metadata
357+ songTitle := filepath .Base (path )
358+ if m , err := tag .ReadFrom (f ); err == nil {
359+ if m .Artist () != "" && m .Title () != "" {
360+ songTitle = fmt .Sprintf ("%s - %s" , m .Artist (), m .Title ())
361+ } else if m .Title () != "" {
362+ songTitle = m .Title ()
363+ }
364+ }
365+ // Seek back to start after reading tags
366+ f .Seek (0 , 0 )
367+
355368 decoder , err := mp3 .NewDecoder (f )
356369 if err != nil {
357370 return err
358371 }
359372
360373 s .mu .Lock ()
361- s .CurrentFile = filepath . Base ( path )
374+ s .CurrentFile = songTitle
362375 s .CurrentFileTime = time .Now ()
363376 s .CurrentFileDuration = time .Duration (decoder .Length ()) * time .Second / (44100 * 2 * 2 ) // Rough estimate for 44.1kHz 16bit stereo
364377 s .mu .Unlock ()
@@ -368,6 +381,7 @@ func (sm *StreamerManager) streamFile(ctx context.Context, s *Streamer, path str
368381 if s .InjectMetadata {
369382 output .CurrentSong = s .CurrentFile
370383 output .Name = s .Name
384+ sm .relay .UpdateMetadata (s .OutputMount , s .CurrentFile )
371385 }
372386 output .Bitrate = fmt .Sprintf ("%d" , s .Bitrate )
373387
0 commit comments