Skip to content

Commit

Permalink
Remove all uses of carriage return when --newlines is set; add --newl…
Browse files Browse the repository at this point in the history
…ines to help message

Closes #155
  • Loading branch information
Kethsar committed Sep 4, 2023
1 parent 6f44209 commit 7faf1a6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
9 changes: 8 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1041,7 +1045,10 @@ func main() {
} else if quiet {
loglevel = LoglevelQuiet
}
log.SetPrefix("\r")

if !statusNewlines {
log.SetPrefix("\r")
}

if forceIPv4 {
networkType = NetworkIPv4
Expand Down
18 changes: 16 additions & 2 deletions player_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 7faf1a6

Please sign in to comment.