From 91a8dcb2bdc26097fb215e9681be2ccabad23a27 Mon Sep 17 00:00:00 2001 From: MichaelOultram Date: Sat, 26 Sep 2015 16:56:50 +0100 Subject: [PATCH] Fixed issue where a single youtube video could not be added --- service.go | 4 +--- service_youtube.go | 5 ++--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/service.go b/service.go index 4e9401e..1e855b5 100644 --- a/service.go +++ b/service.go @@ -90,7 +90,6 @@ 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 { - fmt.Printf("Song loop, title: %s, duration: %d", song.Title(), int(song.Duration().Seconds())) // Check song is not too long if dj.conf.General.MaxSongDuration == 0 || int(song.Duration().Seconds()) <= dj.conf.General.MaxSongDuration { if !isNil(song.Playlist()) { @@ -104,11 +103,10 @@ func FindServiceAndAdd(user *gumble.User, url string) error { songsAdded++ } } - fmt.Printf("Songs added: %d", songsAdded) // Alert channel of added song/playlist if songsAdded == 0 { - return errors.New(TRACK_TOO_LONG_MSG) + return errors.New(fmt.Sprintf(TRACK_TOO_LONG_MSG, urlService.ServiceName())) } else if songsAdded == 1 { dj.client.Self.Channel.Send(fmt.Sprintf(SONG_ADDED_HTML, user.Name, title), false) } else { diff --git a/service_youtube.go b/service_youtube.go index 9883a74..1ef3b7b 100644 --- a/service_youtube.go +++ b/service_youtube.go @@ -64,9 +64,8 @@ func (yt YouTube) NewRequest(user *gumble.User, url string) ([]Song, error) { startOffset = matches[0][2] } song, err := yt.NewSong(user, shortURL, startOffset, nil) - if isNil(song) { - songArray = append(songArray, song) - return songArray, nil + if !isNil(song) { + return append(songArray, song), nil } else { return nil, err }