Fixed duration showing 0:00 when song is less than a minute long
This commit is contained in:
parent
20c2d82ff8
commit
36ff581886
|
@ -77,12 +77,16 @@ func NewYouTubeSong(user, id, offset string, playlist *YouTubePlaylist) (*YouTub
|
||||||
var minutes, seconds int64
|
var minutes, seconds int64
|
||||||
if strings.Contains(duration, "M") {
|
if strings.Contains(duration, "M") {
|
||||||
minutes, _ = strconv.ParseInt(duration[2:strings.Index(duration, "M")], 10, 32)
|
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 {
|
} else {
|
||||||
minutes = 0
|
minutes = 0
|
||||||
}
|
|
||||||
if strings.Contains(duration, "S") {
|
|
||||||
seconds, _ = strconv.ParseInt(duration[strings.Index(duration, "M")+1:len(duration)-1], 10, 32)
|
|
||||||
} else {
|
|
||||||
seconds = 0
|
seconds = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue