diff --git a/service.go b/service.go index 62b6449..d7525a8 100644 --- a/service.go +++ b/service.go @@ -11,7 +11,6 @@ import ( "errors" "fmt" "regexp" - "strconv" "time" "github.com/layeh/gumble/gumble" @@ -75,10 +74,10 @@ func FindServiceAndAdd(user *gumble.User, url string) error { } else { var title string var songsAdded = 0 - var err errors + var err error // Get service to create songs - if songArray, err = urlService.NewRequest(user, url); err != nil { + if songArray, err := urlService.NewRequest(user, url); err != nil { return err } @@ -90,6 +89,7 @@ func FindServiceAndAdd(user *gumble.User, url string) error { // Loop through all songs and add to the queue oldLength := dj.queue.Len() for song := range songArray { + // Check song is not too long time, _ := time.ParseDuration(song.Duration()) if dj.conf.General.MaxSongDuration == 0 || int(time.Seconds()) <= dj.conf.General.MaxSongDuration { if !isNil(song.Playlist()) { @@ -98,11 +98,13 @@ func FindServiceAndAdd(user *gumble.User, url string) error { title = song.Title() } + // Add song to queue dj.queue.AddSong(song) songsAdded++ } } + // Alert channel of added song/playlist if songsAdded == 0 { return errors.New(TRACK_TOO_LONG_MSG) } else if songsAdded == 1 { diff --git a/service_youtube.go b/service_youtube.go index 73df91d..71622c0 100644 --- a/service_youtube.go +++ b/service_youtube.go @@ -8,11 +8,8 @@ package main import ( - "encoding/json" "errors" "fmt" - "io/ioutil" - "net/http" "os" "regexp" "strconv" diff --git a/youtube_dl.go b/youtube_dl.go index 479b43e..983874a 100644 --- a/youtube_dl.go +++ b/youtube_dl.go @@ -8,8 +8,11 @@ package main import ( + "encoding/json" "errors" "fmt" + "io/ioutil" + "net/http" "os" "os/exec" "time"