fix: remove --progress-template, parse default [download] output instead
All checks were successful
CI / build (push) Successful in 40s
All checks were successful
CI / build (push) Successful in 40s
--progress-template output is suppressed in non-TTY subprocesses (yt-dlp issue #13649). The default [download] progress format works reliably in pipes. Changes: - Remove --progress-template from yt-dlp args entirely - Keep --newline for newline-delimited output in pipe - Fix progressRE regex to handle HLS format: ~ with leading spaces before size (e.g. '~ 1.00KiB') - Fix speed parsing in [download] fallback to handle multiple leading spaces (e.g. 'at 976.20B/s') - Fix ETA parsing to strip (frag n/m) suffix - Filter Unknown/N/A speed/eta in [download] fallback - Add test cases for real HLS fragment output format
This commit is contained in:
@@ -11,7 +11,7 @@ import (
|
||||
"uptodownBot/internal/domain"
|
||||
)
|
||||
|
||||
var progressRE = regexp.MustCompile(`\[\w+\]\s+([\d.]+)%\s+of\s+~?([\d.]+)(\w+)`)
|
||||
var progressRE = regexp.MustCompile(`\[\w+\]\s+([\d.]+)%\s+of\s+~?\s*([\d.]+)(\w+)`)
|
||||
var progressTemplateRE = regexp.MustCompile(`^DLPROG\|\s*([\d.]+)%\|\s*(.*?)\s*\|(.*)$`)
|
||||
|
||||
type progressUpdate struct {
|
||||
@@ -71,15 +71,28 @@ func parseProgressLine(line string) *progressUpdate {
|
||||
rest = rest[idx+1:]
|
||||
}
|
||||
if atIdx := strings.Index(rest, " at "); atIdx >= 0 {
|
||||
afterAt := rest[atIdx+4:]
|
||||
afterAt := strings.TrimSpace(rest[atIdx+4:])
|
||||
if spaceIdx := strings.Index(afterAt, " "); spaceIdx >= 0 {
|
||||
u.speed = strings.TrimSpace(afterAt[:spaceIdx])
|
||||
speedVal := afterAt[:spaceIdx]
|
||||
if !strings.EqualFold(speedVal, "unknown") && speedVal != "N/A" {
|
||||
u.speed = speedVal
|
||||
}
|
||||
rest = afterAt[spaceIdx:]
|
||||
} else {
|
||||
if !strings.EqualFold(afterAt, "unknown") && afterAt != "N/A" {
|
||||
u.speed = afterAt
|
||||
}
|
||||
rest = ""
|
||||
}
|
||||
}
|
||||
if etaIdx := strings.Index(rest, "ETA "); etaIdx >= 0 {
|
||||
etaStr := strings.TrimSpace(rest[etaIdx+4:])
|
||||
u.eta = etaStr
|
||||
if parenPos := strings.Index(etaStr, "("); parenPos > 0 {
|
||||
etaStr = strings.TrimSpace(etaStr[:parenPos])
|
||||
}
|
||||
if !strings.EqualFold(etaStr, "unknown") && etaStr != "N/A" {
|
||||
u.eta = etaStr
|
||||
}
|
||||
}
|
||||
|
||||
return u
|
||||
|
||||
Reference in New Issue
Block a user