From 51db9c3061603602fa86f7142bce9b4d63adb278 Mon Sep 17 00:00:00 2001 From: Matthieu Grieger Date: Mon, 22 Aug 2016 20:20:41 -0700 Subject: [PATCH] Fix https://github.com/matthieugrieger/mumbledj/issues/176: Empty IDs for SoundCloud tracks --- CHANGELOG.md | 4 ++++ main.go | 2 +- services/soundcloud.go | 5 +++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2466fc0..5b3b671 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ MumbleDJ Changelog ================== +### August 22, 2016 -- `v3.1.4` +* Fixed a SoundCloud API response parsing issue that would result in empty IDs for tracks. +* Fixed the startup check for SoundCloud API. + ### August 21, 2016 -- `v3.1.3` * Fixed a deadlock that would occur during the transition from the first to second track in a queue. diff --git a/main.go b/main.go index c49dd63..dc1ccc0 100644 --- a/main.go +++ b/main.go @@ -32,7 +32,7 @@ func init() { services.DJ = DJ bot.DJ = DJ - DJ.Version = "v3.1.3" + DJ.Version = "v3.1.4" logrus.SetLevel(logrus.WarnLevel) } diff --git a/services/soundcloud.go b/services/soundcloud.go index 0618640..beaa953 100644 --- a/services/soundcloud.go +++ b/services/soundcloud.go @@ -52,7 +52,7 @@ func (sc *SoundCloud) CheckAPIKey() error { if viper.GetString("api_keys.soundcloud") == "" { return errors.New("No SoundCloud API key has been provided") } - url := "http://api.soundcloud.com/tracks/vjflzpbkmerb?client_id=%s" + url := "http://api.soundcloud.com/tracks/13158665?client_id=%s" response, err := http.Get(fmt.Sprintf(url, viper.GetString("api_keys.soundcloud"))) defer response.Body.Close() if err != nil { @@ -162,7 +162,8 @@ func (sc *SoundCloud) GetTracks(url string, submitter *gumble.User) ([]interface func (sc *SoundCloud) getTrack(obj *jason.Object, offset time.Duration, submitter *gumble.User) (bot.Track, error) { title, _ := obj.GetString("title") - id, _ := obj.GetString("id") + idInt, _ := obj.GetInt64("id") + id := strconv.FormatInt(idInt, 10) url, _ := obj.GetString("permalink_url") author, _ := obj.GetString("user", "username") authorURL, _ := obj.GetString("user", "permalink_url")