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

pull/67/head
Matthieu Grieger 2015-05-09 22:05:05 -07:00
parent 20c2d82ff8
commit 36ff581886
1 changed files with 8 additions and 4 deletions

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
}