do not apply limits if disabled

This commit is contained in:
Niko Storni 2019-07-25 18:22:56 -04:00
parent d5ed4ce753
commit 9d65fce6bc

View file

@ -199,10 +199,6 @@ func (v *YoutubeVideo) download(useIPv6 bool) error {
qualityIndex := 0
ytdlArgs := []string{
"--no-progress",
"--max-filesize",
fmt.Sprintf("%dM", v.maxVideoSize),
"--match-filter",
fmt.Sprintf("duration <= %d", int(math.Round(v.maxVideoLength*3600))),
"-o" + strings.TrimSuffix(v.getFullPath(), ".mp4"),
"--merge-output-format",
"mp4",
@ -212,6 +208,18 @@ func (v *YoutubeVideo) download(useIPv6 bool) error {
"--fragment-retries",
"0",
}
if v.maxVideoSize > 0 {
ytdlArgs = append(ytdlArgs,
"--max-filesize",
fmt.Sprintf("%dM", v.maxVideoSize),
)
}
if v.maxVideoLength > 0 {
ytdlArgs = append(ytdlArgs,
"--match-filter",
fmt.Sprintf("duration <= %d", int(math.Round(v.maxVideoLength*3600))),
)
}
sourceAddress, err := ipManager.GetNextIP(useIPv6)
if err != nil {
if sourceAddress == "throttled" {