Re-add ShufflePlaylist

pull/11/head
Stein Ivar Berghei 2023-10-26 22:50:02 +02:00
parent 891fa050e1
commit 605bd7f29e
1 changed files with 4 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import (
discordspeaker "dndmusicbot/speaker"
"encoding/json"
"log"
"math/rand"
"net/url"
"os"
"strconv"
@ -528,16 +529,18 @@ func (app *App) loadPlaylist(payload ...interface{}) {
}
list, err := ytdl_client.GetPlaylist(pl.Url)
if err != nil {
log.Println("Error getting playlist info,", id)
return
}
rand.Shuffle(len(list.Videos), func(i, j int) { list.Videos[i], list.Videos[j] = list.Videos[j], list.Videos[i] })
app.plmutex.Lock()
if app.plcancel != nil {
app.plcancel()
}
app.mpd.Stop()
app.mpd.Clear()
app.plmutex.Unlock()