no repeats on radio init
This commit is contained in:
parent
8b75345ea3
commit
c3ebf8a792
@ -188,7 +188,12 @@ func RadioGivenSong(ctx *gctx.Context, client *spotify.Client, song_id spotify.I
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
queue := []spotify.ID{song_id}
|
queue := []spotify.ID{song_id}
|
||||||
queue = append(queue, recomendationIds...)
|
all_recs := map[spotify.ID]bool{}
|
||||||
|
all_recs[song_id] = true
|
||||||
|
for _, rec := range recomendationIds {
|
||||||
|
all_recs[rec] = true
|
||||||
|
queue = append(queue, rec)
|
||||||
|
}
|
||||||
_, err = client.AddTracksToPlaylist(ctx, radioPlaylist.ID, queue...)
|
_, err = client.AddTracksToPlaylist(ctx, radioPlaylist.ID, queue...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -607,7 +612,12 @@ func RadioGivenList(ctx *gctx.Context, client *spotify.Client, song_ids []spotif
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
queue := []spotify.ID{song_ids[0]}
|
queue := []spotify.ID{song_ids[0]}
|
||||||
queue = append(queue, recomendationIds...)
|
all_recs := map[spotify.ID]bool{}
|
||||||
|
all_recs[song_ids[0]] = true
|
||||||
|
for _, rec := range recomendationIds {
|
||||||
|
all_recs[rec] = true
|
||||||
|
queue = append(queue, rec)
|
||||||
|
}
|
||||||
_, err = client.AddTracksToPlaylist(ctx, radioPlaylist.ID, queue...)
|
_, err = client.AddTracksToPlaylist(ctx, radioPlaylist.ID, queue...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -633,7 +643,11 @@ func RadioGivenList(ctx *gctx.Context, client *spotify.Client, song_ids []spotif
|
|||||||
}
|
}
|
||||||
additionalRecsIds := []spotify.ID{}
|
additionalRecsIds := []spotify.ID{}
|
||||||
for _, song := range additional_recs.Tracks {
|
for _, song := range additional_recs.Tracks {
|
||||||
|
if _, ok := all_recs[song.ID]; !ok {
|
||||||
|
all_recs[song.ID] = true
|
||||||
additionalRecsIds = append(additionalRecsIds, song.ID)
|
additionalRecsIds = append(additionalRecsIds, song.ID)
|
||||||
|
queue = append(queue, song.ID)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_, err = client.AddTracksToPlaylist(ctx, radioPlaylist.ID, additionalRecsIds...)
|
_, err = client.AddTracksToPlaylist(ctx, radioPlaylist.ID, additionalRecsIds...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user