Soundcloud uses avatar if song has no artwork [ci skip]

This commit is contained in:
MichaelOultram 2015-08-13 15:32:20 +01:00
parent cf6946b8bf
commit bceaa27085

View file

@ -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 {
// 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