From 89f7cbe57ac71fa25090e5d3d15b80880f5b8ae6 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Fri, 22 Sep 2023 22:41:09 +0300 Subject: [PATCH] fix: concurrnet fragment arguments: exec.cmd does now allow flag+val strings. sperate the two --- downloader.go | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/downloader.go b/downloader.go index 0193a86..68afcf7 100644 --- a/downloader.go +++ b/downloader.go @@ -12,7 +12,8 @@ import ( const YT_DLP string = "yt-dlp" const YT_DLP_FLAG_GET_TITLE string = "--get-title" const YT_DLP_FLAG_EMBED_METADATA string = "--embed-metadata" -const YT_DLP_FLAG_CONCURRENT_FRAGMENTS string = "--concurrent-fragments 4" +const YT_DLP_FLAG_CONCURRENT_FRAGMENTS string = "--concurrent-fragments" +const YT_DLP_FLAG_CONCURRENT_FRAGMENTS_COUNT string = "4" const JOB_STATUS_NEW = 1 const JOB_STATUS_COMPLETED = 2 @@ -34,21 +35,10 @@ func Download(links *[]string) { var jobs []DownloadCtx startedGoRoutines := 0 + pw := progress.NewWriter() - pw.SetStyle(progress.StyleDefault) - pw.SetTrackerLength(10) + setupProgressWriter(pw) pw.SetNumTrackersExpected(len(*links)) - pw.SetUpdateFrequency(time.Millisecond * 100) - pw.Style().Colors = progress.StyleColorsExample - pw.SetTrackerPosition(progress.PositionLeft) - pw.Style().Visibility.ETA = false - pw.Style().Visibility.ETAOverall = false - pw.Style().Visibility.Speed = false - pw.Style().Visibility.Percentage = false - pw.Style().Visibility.Value = false - pw.Style().Visibility.TrackerOverall = true - pw.Style().Options.TimeInProgressPrecision = time.Second - pw.Style().Options.TimeDonePrecision = time.Second go pw.Render() @@ -116,6 +106,7 @@ func getTitle(ctx *DownloadCtx) { YT_DLP_FLAG_GET_TITLE, YT_DLP_FLAG_EMBED_METADATA, YT_DLP_FLAG_CONCURRENT_FRAGMENTS, + YT_DLP_FLAG_CONCURRENT_FRAGMENTS_COUNT, ctx.link, ) stdout, err := cmd.Output() @@ -144,3 +135,21 @@ func ytdlpDownload( ctx.status = JOB_STATUS_COMPLETED } + +func setupProgressWriter(pw progress.Writer) { + + pw.SetStyle(progress.StyleDefault) + pw.SetTrackerLength(10) + pw.SetUpdateFrequency(time.Millisecond * 100) + pw.Style().Colors = progress.StyleColorsExample + pw.SetTrackerPosition(progress.PositionLeft) + pw.Style().Visibility.ETA = false + pw.Style().Visibility.ETAOverall = false + pw.Style().Visibility.Speed = false + pw.Style().Visibility.Percentage = false + pw.Style().Visibility.Value = false + pw.Style().Visibility.TrackerOverall = true + pw.Style().Options.TimeInProgressPrecision = time.Second + pw.Style().Options.TimeDonePrecision = time.Second + +}