add similar songs fallback when server returns none

This commit is contained in:
Drew Weymouth
2024-06-24 08:23:49 -07:00
parent 17dfa1132f
commit 7f6335c428
3 changed files with 38 additions and 0 deletions
@@ -14,6 +14,7 @@ import (
"github.com/dweymouth/go-subsonic/subsonic"
"github.com/dweymouth/supersonic/backend/mediaprovider"
"github.com/dweymouth/supersonic/backend/mediaprovider/helpers"
"github.com/dweymouth/supersonic/sharedutil"
)
@@ -622,5 +623,12 @@ func (s *subsonicMediaProvider) GetSongRadio(trackID string, count int) ([]*medi
if err != nil {
return nil, err
}
if len(tr) == 0 {
track, err := s.GetTrack(trackID)
if err != nil {
return nil, err
}
return helpers.GetSimilarSongsFallback(s, track, count), nil
}
return sharedutil.MapSlice(tr, toTrack), nil
}