Fixed duration showing 0:00 when song is less than a minute long

This commit is contained in:
Matthieu Grieger 2015-05-09 22:05:05 -07:00
parent 20c2d82ff8
commit 36ff581886

View file

@ -77,12 +77,16 @@ func NewYouTubeSong(user, id, offset string, playlist *YouTubePlaylist) (*YouTub
var minutes, seconds int64
if strings.Contains(duration, "M") {
minutes, _ = strconv.ParseInt(duration[2:strings.Index(duration, "M")], 10, 32)
if strings.Contains(duration, "S") {
seconds, _ = strconv.ParseInt(duration[strings.Index(duration, "M")+1:len(duration)-1], 10, 32)
} else {
seconds = 0
}
} else if strings.Contains(duration, "S") {
minutes = 0
seconds, _ = strconv.ParseInt(duration[2:len(duration)-1], 10, 32)
} else {
minutes = 0
}
if strings.Contains(duration, "S") {
seconds, _ = strconv.ParseInt(duration[strings.Index(duration, "M")+1:len(duration)-1], 10, 32)
} else {
seconds = 0
}