From 1760935edf3aef3560508de3e478a5e877471473 Mon Sep 17 00:00:00 2001 From: Niko Storni Date: Mon, 22 Jul 2019 02:09:18 +0200 Subject: [PATCH] don't retry missing fragments lower syncing quality for now --- sources/youtubeVideo.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/sources/youtubeVideo.go b/sources/youtubeVideo.go index 844d00e..7052024 100644 --- a/sources/youtubeVideo.go +++ b/sources/youtubeVideo.go @@ -190,16 +190,25 @@ func (v *YoutubeVideo) download(useIPv6 bool) error { log.Debugln(v.id + " already exists at " + videoPath) return nil } - + qualities := []string{ + //"1080", + "720", + "480", + "320", + } + 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))), - "-fbestvideo[ext=mp4][height<=1080]+bestaudio[ext!=webm]", + "-fbestvideo[ext=mp4][height<=" + qualities[qualityIndex] + "]+bestaudio[ext!=webm]", "-o" + strings.TrimSuffix(v.getFullPath(), ".mp4"), "--merge-output-format", + "--abort-on-unavailable-fragment", + "--fragment-retries", + "0", "mp4", } sourceAddress, err := ipManager.GetNextIP(useIPv6) @@ -239,6 +248,7 @@ func (v *YoutubeVideo) download(useIPv6 bool) error { ) } ytdlArgs = append(ytdlArgs, "https://www.youtube.com/watch?v="+v.ID()) +runcmd: cmd := exec.Command("youtube-dl", ytdlArgs...) log.Printf("Running command and waiting for it to finish...") @@ -265,6 +275,9 @@ func (v *YoutubeVideo) download(useIPv6 bool) error { ipManager.SetIpThrottled(sourceAddress, v.stopGroup) } return errors.Err(string(errorLog)) + } else if strings.Contains(string(errorLog), "giving up after 0 fragment retries") && qualityIndex < len(qualities)-1 { + qualityIndex++ + goto runcmd } return errors.Err(err) }