Re-add ShufflePlaylist
parent
891fa050e1
commit
605bd7f29e
|
@ -6,6 +6,7 @@ import (
|
||||||
discordspeaker "dndmusicbot/speaker"
|
discordspeaker "dndmusicbot/speaker"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"log"
|
"log"
|
||||||
|
"math/rand"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -528,16 +529,18 @@ func (app *App) loadPlaylist(payload ...interface{}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
list, err := ytdl_client.GetPlaylist(pl.Url)
|
list, err := ytdl_client.GetPlaylist(pl.Url)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Error getting playlist info,", id)
|
log.Println("Error getting playlist info,", id)
|
||||||
return
|
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()
|
app.plmutex.Lock()
|
||||||
if app.plcancel != nil {
|
if app.plcancel != nil {
|
||||||
app.plcancel()
|
app.plcancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
app.mpd.Stop()
|
app.mpd.Stop()
|
||||||
app.mpd.Clear()
|
app.mpd.Clear()
|
||||||
app.plmutex.Unlock()
|
app.plmutex.Unlock()
|
||||||
|
|
Loading…
Reference in New Issue