remove dups

This commit is contained in:
a 2025-02-10 14:28:49 -06:00
parent f48f7df9e3
commit 82a92ecc9a
No known key found for this signature in database
GPG Key ID: 2F22877AA4DFDADB

@ -27,7 +27,7 @@ func (c *Commander) GetRecomendationIdsForPrompt(ctx context.Context, prompt str
if err != nil { if err != nil {
return nil, err return nil, err
} }
ids := []spotify.ID{} isMap := map[spotify.ID]struct{}{}
for _, v := range radioResp.Tracks { for _, v := range radioResp.Tracks {
match, err := c.lb.MatchTrack(ctx, &v) match, err := c.lb.MatchTrack(ctx, &v)
if err != nil { if err != nil {
@ -41,9 +41,13 @@ func (c *Commander) GetRecomendationIdsForPrompt(ctx context.Context, prompt str
if match.SpotifyId == "" { if match.SpotifyId == "" {
continue continue
} }
ids = append(ids, spotify.ID(match.SpotifyId)) isMap[spotify.ID(match.SpotifyId)] = struct{}{}
} }
return ids, nil keys := make([]spotify.ID, 0, len(isMap))
for i := range isMap {
keys = append(keys, i)
}
return keys, nil
} }
func (c *Commander) RadioFromPrompt(ctx context.Context, prompt string, mode string) error { func (c *Commander) RadioFromPrompt(ctx context.Context, prompt string, mode string) error {