Fixed issue where a single youtube video could not be added
This commit is contained in:
parent
1aebcfce77
commit
91a8dcb2bd
|
@ -90,7 +90,6 @@ func FindServiceAndAdd(user *gumble.User, url string) error {
|
||||||
// Loop through all songs and add to the queue
|
// Loop through all songs and add to the queue
|
||||||
oldLength := dj.queue.Len()
|
oldLength := dj.queue.Len()
|
||||||
for _, song := range songArray {
|
for _, song := range songArray {
|
||||||
fmt.Printf("Song loop, title: %s, duration: %d", song.Title(), int(song.Duration().Seconds()))
|
|
||||||
// Check song is not too long
|
// Check song is not too long
|
||||||
if dj.conf.General.MaxSongDuration == 0 || int(song.Duration().Seconds()) <= dj.conf.General.MaxSongDuration {
|
if dj.conf.General.MaxSongDuration == 0 || int(song.Duration().Seconds()) <= dj.conf.General.MaxSongDuration {
|
||||||
if !isNil(song.Playlist()) {
|
if !isNil(song.Playlist()) {
|
||||||
|
@ -104,11 +103,10 @@ func FindServiceAndAdd(user *gumble.User, url string) error {
|
||||||
songsAdded++
|
songsAdded++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Printf("Songs added: %d", songsAdded)
|
|
||||||
|
|
||||||
// Alert channel of added song/playlist
|
// Alert channel of added song/playlist
|
||||||
if songsAdded == 0 {
|
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 {
|
} else if songsAdded == 1 {
|
||||||
dj.client.Self.Channel.Send(fmt.Sprintf(SONG_ADDED_HTML, user.Name, title), false)
|
dj.client.Self.Channel.Send(fmt.Sprintf(SONG_ADDED_HTML, user.Name, title), false)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -64,9 +64,8 @@ func (yt YouTube) NewRequest(user *gumble.User, url string) ([]Song, error) {
|
||||||
startOffset = matches[0][2]
|
startOffset = matches[0][2]
|
||||||
}
|
}
|
||||||
song, err := yt.NewSong(user, shortURL, startOffset, nil)
|
song, err := yt.NewSong(user, shortURL, startOffset, nil)
|
||||||
if isNil(song) {
|
if !isNil(song) {
|
||||||
songArray = append(songArray, song)
|
return append(songArray, song), nil
|
||||||
return songArray, nil
|
|
||||||
} else {
|
} else {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue