Timeout random track fetch
continuous-integration/drone/push Build is passing Details

This commit is contained in:
DataHoarder 2022-08-27 22:10:07 +02:00
parent eec79cb3ab
commit 995acf48b9
Signed by: DataHoarder
SSH Key Fingerprint: SHA256:OLTRf6Fl87G52SiR7sWLGNzlJt4WOX+tfI2yxo0z7xk
1 changed files with 7 additions and 1 deletions

8
api.go
View File

@ -12,6 +12,7 @@ import (
"strconv"
"strings"
"sync"
"time"
)
type API struct {
@ -77,8 +78,12 @@ func (a *API) getFallbackTrack() (*QueueTrackEntry, error) {
original: m,
}, nil
}
func (a *API) getRandomTrack() (*QueueTrackEntry, error) {
response, err := http.DefaultClient.Get(a.config.Queue.RandomSongApi)
response, err := (&http.Client{
Timeout: time.Second * 60,
}).Get(a.config.Queue.RandomSongApi)
if err != nil {
return nil, err
}
@ -91,6 +96,7 @@ func (a *API) getRandomTrack() (*QueueTrackEntry, error) {
return a.getQueueEntryFromBody(body)
}
func (a *API) setNowRandom(nr *QueueTrackEntry) {
a.nr = nr
if a.config.Queue.NowRandom != "" {