From 3c4513ae32e483487959a00dfad805aabea88698 Mon Sep 17 00:00:00 2001 From: MichaelOultram Date: Sun, 16 Aug 2015 02:14:08 +0100 Subject: [PATCH] Soundcloud links with a time will be offset --- service_soundcloud.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/service_soundcloud.go b/service_soundcloud.go index cf5a76b..48ebbb1 100644 --- a/service_soundcloud.go +++ b/service_soundcloud.go @@ -66,8 +66,9 @@ func (sc SoundCloud) NewRequest(user *gumble.User, url string) (string, error) { // Calculating offset offset := 0 timesplit := strings.Split(url, "#t=") - if timesplit.Length == 2 { - offset = time.ParseDuration(timesplit[1]).Seconds() + if timesplit.Size == 2 { + duration, _ := time.ParseDuration(timesplit[1]) + offset = duration.Seconds() } return sc.NewSong(user, apiResponse, offset, nil) @@ -89,8 +90,8 @@ func (sc SoundCloud) NewSong(user *gumble.User, trackData *jsonq.JsonQuery, offs // Check song is not longer than the MaxSongDuration if dj.conf.General.MaxSongDuration == 0 || (durationMS/1000) <= dj.conf.General.MaxSongDuration { - duration, _ := time.ParseDuration(strconv.Itoa(durationMS) + "ms") - duration = strings.NewReplacer("h", ":", "m", ":", "s", ":").Replace(duration.String()) + timeDuration, _ := time.ParseDuration(strconv.Itoa(durationMS) + "ms") + duration = strings.NewReplacer("h", ":", "m", ":", "s", ":").Replace(timeDuration.String()) song := &YouTubeSong{ id: strconv.Itoa(id),