Fix time indicator for soundcloud music
Some checks failed
Run Integration Tests / test (push) Failing after 37s
Some checks failed
Run Integration Tests / test (push) Failing after 37s
This commit is contained in:
parent
f8c4318b3d
commit
fe0d80007f
1 changed files with 14 additions and 1 deletions
|
@ -84,6 +84,19 @@ func convertSoundCloudResults(tracks []SoundCloudTrack) []MusicResult {
|
||||||
track.Permalink,
|
track.Permalink,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Convert ms to hh:mm:ss
|
||||||
|
totalSeconds := track.Duration / 1000
|
||||||
|
hours := totalSeconds / 3600
|
||||||
|
minutes := (totalSeconds % 3600) / 60
|
||||||
|
seconds := totalSeconds % 60
|
||||||
|
|
||||||
|
var durationStr string
|
||||||
|
if hours > 0 {
|
||||||
|
durationStr = fmt.Sprintf("%d:%02d:%02d", hours, minutes, seconds)
|
||||||
|
} else {
|
||||||
|
durationStr = fmt.Sprintf("%d:%02d", minutes, seconds)
|
||||||
|
}
|
||||||
|
|
||||||
results = append(results, MusicResult{
|
results = append(results, MusicResult{
|
||||||
Title: track.Title,
|
Title: track.Title,
|
||||||
Artist: track.User.Username,
|
Artist: track.User.Username,
|
||||||
|
@ -91,7 +104,7 @@ func convertSoundCloudResults(tracks []SoundCloudTrack) []MusicResult {
|
||||||
Thumbnail: thumbnail,
|
Thumbnail: thumbnail,
|
||||||
//AudioURL: track.Streams.HTTPMP3128URL,
|
//AudioURL: track.Streams.HTTPMP3128URL,
|
||||||
Source: "SoundCloud",
|
Source: "SoundCloud",
|
||||||
Duration: fmt.Sprintf("%d", track.Duration/1000),
|
Duration: durationStr,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return results
|
return results
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue