From bceaa27085d70210b5bcaef0ec698a89bb5c444f Mon Sep 17 00:00:00 2001 From: MichaelOultram Date: Thu, 13 Aug 2015 15:32:20 +0100 Subject: [PATCH] Soundcloud uses avatar if song has no artwork [ci skip] --- service_soundcloud.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/service_soundcloud.go b/service_soundcloud.go index 0ba4b5d..4e47e8d 100644 --- a/service_soundcloud.go +++ b/service_soundcloud.go @@ -80,18 +80,30 @@ func (sc SoundCloud) NewSong(user *gumble.User, trackData *jsonq.JsonQuery, play if err != nil { return "", err } + id, err := trackData.Int("id") if err != nil { return "", err } + duration, err := trackData.Int("duration") if err != nil { return "", err } thumbnail, err := trackData.String("artwork_url") if err != nil { - return "", err + // Song has no artwork, using profile avatar instead + userObj, err := trackData.Object("user") + if err != nil { + return "", err + } + + thumbnail, err = jsonq.NewQuery(userObj).String("avatar_url") + if err != nil { + return "", err + } } + url, err := trackData.String("permalink_url") if err != nil { return "", err