From 7faf1a697096a92f21f3982713a3b6e56bc4af46 Mon Sep 17 00:00:00 2001 From: Kethsar Date: Mon, 4 Sep 2023 15:22:05 -0700 Subject: [PATCH] Remove all uses of carriage return when --newlines is set; add --newlines to help message Closes #155 --- main.go | 9 ++++++++- player_response.go | 18 ++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index d17ccdc..1c361d7 100644 --- a/main.go +++ b/main.go @@ -124,6 +124,10 @@ Options: Be careful to monitor your disk usage when using this to avoid filling your drive while away. + --newline + Print every message to a new line, instead of some messages reusing one + line. + --no-audio Do not download the audio stream @@ -1041,7 +1045,10 @@ func main() { } else if quiet { loglevel = LoglevelQuiet } - log.SetPrefix("\r") + + if !statusNewlines { + log.SetPrefix("\r") + } if forceIPv4 { networkType = NetworkIPv4 diff --git a/player_response.go b/player_response.go index bead29b..3fc0f36 100644 --- a/player_response.go +++ b/player_response.go @@ -397,7 +397,14 @@ func (di *DownloadInfo) GetPlayablePlayerResponse() (retrieved int, pr *PlayerRe liveWaited += di.RetrySecs retryCount += 1 if loglevel > LoglevelQuiet { - fmt.Fprintf(os.Stderr, "\rRetries: %d (Last retry: %s), Total time waited: %d seconds", + msg := "Retries: %d (Last retry: %s), Total time waited: %d seconds" + if !statusNewlines { + msg = "\r" + msg + } else { + msg = msg + "\n" + } + + fmt.Fprintf(os.Stderr, msg, retryCount, time.Now().Format("2006/01/02 15:04:05"), liveWaited, @@ -499,7 +506,14 @@ func (di *DownloadInfo) GetPlayablePlayerResponse() (retrieved int, pr *PlayerRe liveWaited += di.RetrySecs retryCount += 1 if loglevel > LoglevelQuiet { - fmt.Fprintf(os.Stderr, "\rRetries: %d (Last retry: %s), Total time waited: %d seconds", + msg := "Retries: %d (Last retry: %s), Total time waited: %d seconds" + if !statusNewlines { + msg = "\r" + msg + } else { + msg = msg + "\n" + } + + fmt.Fprintf(os.Stderr, msg, retryCount, time.Now().Format("2006/01/02 15:04:05"), liveWaited,