Timeout random track fetch
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
eec79cb3ab
commit
995acf48b9
8
api.go
8
api.go
|
@ -12,6 +12,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type API struct {
|
type API struct {
|
||||||
|
@ -77,8 +78,12 @@ func (a *API) getFallbackTrack() (*QueueTrackEntry, error) {
|
||||||
original: m,
|
original: m,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *API) getRandomTrack() (*QueueTrackEntry, error) {
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -91,6 +96,7 @@ func (a *API) getRandomTrack() (*QueueTrackEntry, error) {
|
||||||
|
|
||||||
return a.getQueueEntryFromBody(body)
|
return a.getQueueEntryFromBody(body)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *API) setNowRandom(nr *QueueTrackEntry) {
|
func (a *API) setNowRandom(nr *QueueTrackEntry) {
|
||||||
a.nr = nr
|
a.nr = nr
|
||||||
if a.config.Queue.NowRandom != "" {
|
if a.config.Queue.NowRandom != "" {
|
||||||
|
|
Loading…
Reference in a new issue