Fixed panic when a song exceeded allowed duration

This commit is contained in:
Jake 2015-02-17 19:47:57 +00:00 committed by Jake
parent 541f371239
commit 38be691913

View file

@ -58,9 +58,9 @@ func NewPlaylist(user, id string) (*Playlist, error) {
id: id, id: id,
title: playlistTitle, title: playlistTitle,
} }
j := 0
for i := 0; i < playlistItems; i++ { for i := 0; i < playlistItems; i++ {
index := strconv.Itoa(i) index := strconv.Itoa(j)
songTitle, _ := jq.String("data", "items", index, "video", "title") songTitle, _ := jq.String("data", "items", index, "video", "title")
songId, _ := jq.String("data", "items", index, "video", "id") songId, _ := jq.String("data", "items", index, "video", "id")
songThumbnail, _ := jq.String("data", "items", index, "video", "thumbnail", "hqDefault") songThumbnail, _ := jq.String("data", "items", index, "video", "thumbnail", "hqDefault")
@ -78,7 +78,8 @@ func NewPlaylist(user, id string) (*Playlist, error) {
// Don't spam the chat if a playlist contains songs that are too long // Don't spam the chat if a playlist contains songs that are too long
if dj.conf.General.MaxSongDuration == 0 || duration <= dj.conf.General.MaxSongDuration { if dj.conf.General.MaxSongDuration == 0 || duration <= dj.conf.General.MaxSongDuration {
dj.queue.AddSong(newSong) dj.queue.AddSong(newSong)
} j += 1
}
} }
return playlist, nil return playlist, nil