make proxy recursive
Marco Andronaco andronacomarco@gmail.com
Mon, 01 Jan 2024 22:32:24 +0100
1 files changed,
13 insertions(+),
4 deletions(-)
jump to
M
invidious/invidious.go
→
invidious/invidious.go
@@ -163,8 +163,9 @@ http.Error(w, "Bad Request", http.StatusBadRequest)
return err } - idx := formatIndex % len(video.Formats) - url := video.Formats[len(video.Formats)-1-idx].Url + fmtAmount := len(video.Formats) + idx := formatIndex % fmtAmount + url := video.Formats[fmtAmount-1-idx].Url req, err := http.NewRequest(http.MethodGet, url, nil) if err != nil { log.Fatal(err)@@ -188,8 +189,16 @@
w.Header().Set("content-type", "video/mp4") w.Header().Set("Status", "200") - i, err := io.Copy(w, resp.Body) - fmt.Println(i, err) + _, err = io.Copy(w, resp.Body) + if err == nil { // done + return nil + } + + newIndex := formatIndex + 1 + if newIndex < fmtAmount { + return c.ProxyVideo(w, videoId, newIndex) + } + return err }