fix: concurrnet fragment arguments:

exec.cmd does now allow flag+val strings.
	sperate the two
This commit is contained in:
HeshamTB 2023-09-22 22:41:09 +03:00
parent e1056f0d84
commit 89f7cbe57a

View File

@ -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
}