diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a8e430..e7757aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ MumbleDJ Changelog ================== +### January 9, 2015 -- `v2.2.5` +* Fixed some YouTube playlist URLs crashing the bot and not retrieving metadata correctly. + ### January 8, 2015 -- `v2.2.4` * Fixed a crash caused by a user trying to skip the same song more than once. diff --git a/commands.go b/commands.go index 11b2486..fc0aa9e 100644 --- a/commands.go +++ b/commands.go @@ -148,20 +148,22 @@ func add(user *gumble.User, username, url string) { } } else { // Check to see if we have a playlist URL instead. - youtubePlaylistPattern := `https?:\/\/www\.youtube\.com\/playlist\?list=(\w+)` + youtubePlaylistPattern := `https?:\/\/www\.youtube\.com\/playlist\?list=([\w-]+)` if re, err := regexp.Compile(youtubePlaylistPattern); err == nil { if re.MatchString(url) { if dj.HasPermission(username, dj.conf.Permissions.AdminAddPlaylists) { shortUrl = re.FindStringSubmatch(url)[1] - newPlaylist := NewPlaylist(username, shortUrl) - if dj.queue.AddItem(newPlaylist); err == nil { - dj.client.Self().Channel().Send(fmt.Sprintf(PLAYLIST_ADDED_HTML, username, newPlaylist.title), false) - if dj.queue.Len() == 1 && !dj.audioStream.IsPlaying() { - if err := dj.queue.CurrentItem().(*Playlist).songs.CurrentItem().(*Song).Download(); err == nil { - dj.queue.CurrentItem().(*Playlist).songs.CurrentItem().(*Song).Play() - } else { - user.Send(AUDIO_FAIL_MSG) - dj.queue.CurrentItem().(*Playlist).songs.CurrentItem().(*Song).Delete() + if shortUrl != nil { + newPlaylist := NewPlaylist(username, shortUrl) + if dj.queue.AddItem(newPlaylist); err == nil { + dj.client.Self().Channel().Send(fmt.Sprintf(PLAYLIST_ADDED_HTML, username, newPlaylist.title), false) + if dj.queue.Len() == 1 && !dj.audioStream.IsPlaying() { + if err := dj.queue.CurrentItem().(*Playlist).songs.CurrentItem().(*Song).Download(); err == nil { + dj.queue.CurrentItem().(*Playlist).songs.CurrentItem().(*Song).Play() + } else { + user.Send(AUDIO_FAIL_MSG) + dj.queue.CurrentItem().(*Playlist).songs.CurrentItem().(*Song).Delete() + } } } }