fix: read yt-dlp progress from stdout instead of stderr; add explicit --proxy support
All checks were successful
CI / build (push) Successful in 52s

This commit is contained in:
2026-06-26 00:41:04 +03:30
parent df08a8840f
commit 58baa1b769
2 changed files with 45 additions and 12 deletions

View File

@@ -98,22 +98,16 @@ func parseProgressLine(line string) *progressUpdate {
return u
}
// readProgress reads yt-dlp stderr and sends progress updates to the channel.
// readProgress reads yt-dlp output and sends progress updates to the channel.
// The caller is responsible for closing the updates channel.
func readProgress(stderr io.ReadCloser, updates chan<- *domain.DownloadJob, job *domain.DownloadJob) {
var stderrBuf strings.Builder
scanner := bufio.NewScanner(stderr)
func readProgress(reader io.ReadCloser, updates chan<- *domain.DownloadJob, job *domain.DownloadJob) {
scanner := bufio.NewScanner(reader)
lineCount := 0
matchCount := 0
for scanner.Scan() {
line := scanner.Text()
lineCount++
if stderrBuf.Len() < 4096 {
stderrBuf.WriteString(line)
stderrBuf.WriteByte('\n')
}
parsed := parseProgressLine(line)
if parsed == nil {
continue
@@ -124,6 +118,5 @@ func readProgress(stderr io.ReadCloser, updates chan<- *domain.DownloadJob, job
job.ETA = parsed.eta
updates <- job
}
job.StderrLog = stderrBuf.String()
slog.Info("readProgress finished", "url", job.URL, "lines", lineCount, "matches", matchCount, "stderr_len", len(job.StderrLog))
slog.Info("readProgress finished", "url", job.URL, "lines", lineCount, "matches", matchCount)
}