Compare commits

...
2 Commits
Author SHA1 Message Date
Niko Storni 64ab2490fe fix bugs
improve debugging
2019-07-22 02:27:14 +02:00
Niko Storni 1760935edf don't retry missing fragments
lower syncing quality for now
2019-07-22 02:09:18 +02:00
+17 -4
View File
@@ -190,17 +190,26 @@ 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]",
"-o" + strings.TrimSuffix(v.getFullPath(), ".mp4"),
"-fbestvideo[ext=mp4][height<=" + qualities[qualityIndex] + "]+bestaudio[ext!=webm]",
"-o\"" + strings.TrimSuffix(v.getFullPath(), ".mp4") + "\"",
"--merge-output-format",
"mp4",
"--abort-on-unavailable-fragment",
"--fragment-retries",
"0",
}
sourceAddress, err := ipManager.GetNextIP(useIPv6)
if err != nil {
@@ -239,9 +248,10 @@ 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...")
log.Printf("Running command youtube-dl %s", strings.Join(ytdlArgs, " "))
stderr, err := cmd.StderrPipe()
if err != nil {
@@ -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)
}