Skip to content

Commit

Permalink
exclude track itself from similar tracks in either codepath
Browse files Browse the repository at this point in the history
  • Loading branch information
dweymouth committed Jun 24, 2024
1 parent 7f6335c commit 1ddc6dc
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions backend/mediaprovider/helpers/similar.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ func GetSimilarSongsFallback(mp mediaprovider.MediaProvider, track *mediaprovide
var tracks []*mediaprovider.Track
if len(track.ArtistIDs) > 0 {
tracks, _ = mp.GetSimilarTracks(track.ArtistIDs[0], count)
if len(tracks) > 0 {
return tracks
}
}
tracks, _ = mp.GetRandomTracks(track.Genre, count)
if len(tracks) == 0 {
tracks, _ = mp.GetRandomTracks(track.Genre, count)
}

// make sure to exclude the song itself from the similar list
return sharedutil.FilterSlice(tracks, func(t *mediaprovider.Track) bool {
Expand Down

0 comments on commit 1ddc6dc

Please sign in to comment.