Soundcloud links with a time will be offset
This commit is contained in:
parent
79305a408d
commit
3c4513ae32
|
@ -66,8 +66,9 @@ func (sc SoundCloud) NewRequest(user *gumble.User, url string) (string, error) {
|
||||||
// Calculating offset
|
// Calculating offset
|
||||||
offset := 0
|
offset := 0
|
||||||
timesplit := strings.Split(url, "#t=")
|
timesplit := strings.Split(url, "#t=")
|
||||||
if timesplit.Length == 2 {
|
if timesplit.Size == 2 {
|
||||||
offset = time.ParseDuration(timesplit[1]).Seconds()
|
duration, _ := time.ParseDuration(timesplit[1])
|
||||||
|
offset = duration.Seconds()
|
||||||
}
|
}
|
||||||
|
|
||||||
return sc.NewSong(user, apiResponse, offset, nil)
|
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
|
// Check song is not longer than the MaxSongDuration
|
||||||
if dj.conf.General.MaxSongDuration == 0 || (durationMS/1000) <= dj.conf.General.MaxSongDuration {
|
if dj.conf.General.MaxSongDuration == 0 || (durationMS/1000) <= dj.conf.General.MaxSongDuration {
|
||||||
duration, _ := time.ParseDuration(strconv.Itoa(durationMS) + "ms")
|
timeDuration, _ := time.ParseDuration(strconv.Itoa(durationMS) + "ms")
|
||||||
duration = strings.NewReplacer("h", ":", "m", ":", "s", ":").Replace(duration.String())
|
duration = strings.NewReplacer("h", ":", "m", ":", "s", ":").Replace(timeDuration.String())
|
||||||
|
|
||||||
song := &YouTubeSong{
|
song := &YouTubeSong{
|
||||||
id: strconv.Itoa(id),
|
id: strconv.Itoa(id),
|
||||||
|
|
Reference in a new issue