From b39eb72cb98d22c07bc7ff2ea2fc4771574b1e6f Mon Sep 17 00:00:00 2001 From: Matthieu Grieger Date: Tue, 12 May 2015 22:55:06 -0700 Subject: [PATCH] Cleaned up timestamp display --- service_youtube.go | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/service_youtube.go b/service_youtube.go index 3c73f93..1712c13 100644 --- a/service_youtube.go +++ b/service_youtube.go @@ -102,7 +102,16 @@ func NewYouTubeSong(user, id, offset string, playlist *YouTubePlaylist) (*YouTub } totalSeconds := int((days * 86400) + (hours * 3600) + (minutes * 60) + seconds) - durationString := fmt.Sprintf("%02d:%02d:%02d:%02d", days, hours, minutes, seconds) + var durationString string + if hours != 0 { + if days != 0 { + durationString = fmt.Sprintf("%d:%02d:%02d:%02d", days, hours, minutes, seconds) + } else { + durationString = fmt.Sprintf("%d:%02d:%02d", hours, minutes, seconds) + } + } else { + durationString = fmt.Sprintf("%d:%02d", minutes, seconds) + } if dj.conf.General.MaxSongDuration == 0 || totalSeconds <= dj.conf.General.MaxSongDuration { song := &YouTubeSong{ @@ -363,7 +372,16 @@ func NewYouTubePlaylist(user, id string) (*YouTubePlaylist, error) { } totalSeconds := int((days * 86400) + (hours * 3600) + (minutes * 60) + seconds) - durationString := fmt.Sprintf("%02d:%02d:%02d:%02d", days, hours, minutes, seconds) + var durationString string + if hours != 0 { + if days != 0 { + durationString = fmt.Sprintf("%d:%02d:%02d:%02d", days, hours, minutes, seconds) + } else { + durationString = fmt.Sprintf("%d:%02d:%02d", hours, minutes, seconds) + } + } else { + durationString = fmt.Sprintf("%d:%02d", minutes, seconds) + } if dj.conf.General.MaxSongDuration == 0 || totalSeconds <= dj.conf.General.MaxSongDuration { playlistSong := &YouTubeSong{