From 08e8607f5f5064e4fd58adb7eedb235e8ff0dcbc Mon Sep 17 00:00:00 2001 From: Fijxu Date: Fri, 13 Dec 2024 18:52:29 -0300 Subject: [PATCH] Revert "use invidious-companion ways of adding headers and queries" Not dealing with this shit now This reverts commit 82185f4a2811b185443e9c3d01d1b93a454c8f4c. --- httppaths.go | 33 +++------------------------------ 1 file changed, 3 insertions(+), 30 deletions(-) diff --git a/httppaths.go b/httppaths.go index b984668..8dac3fe 100644 --- a/httppaths.go +++ b/httppaths.go @@ -33,24 +33,10 @@ func videoplayback(w http.ResponseWriter, req *http.Request) { // Prevent the process of already expired playbacks // since they will return 403 from googlevideo servers. if (expire - time.Now().Unix()) <= 0 { - w.WriteHeader(400) - io.WriteString(w, "Expire query string undefined or videoplayback URL has expired.") + w.WriteHeader(403) return } - // https://github.com/iv-org/invidious-companion/blob/306f2d5f12440275e3202a52e8555eb88d9a34be/src/routes/videoPlaybackProxy.ts#L41-L45 - c := q.Get("c") - if c == "" { - w.WriteHeader(400) - io.WriteString(w, "'c' query string undefined.") - return - } - - // https://github.com/iv-org/invidious-companion/blob/306f2d5f12440275e3202a52e8555eb88d9a34be/src/routes/videoPlaybackProxy.ts#L56-L58 - if strings.Contains(c, "WEB") { - q.Add("alr", "yes") - } - host := q.Get("host") q.Del("host") @@ -73,8 +59,6 @@ func videoplayback(w http.ResponseWriter, req *http.Request) { host = "rr" + mvi + "---" + mn[0] + ".googlevideo.com" } - // https://github.com/iv-org/invidious-companion/blob/306f2d5f12440275e3202a52e8555eb88d9a34be/src/routes/videoPlaybackProxy.ts#L56-L58 - parts := strings.Split(strings.ToLower(host), ".") if len(parts) < 2 { @@ -111,22 +95,11 @@ func videoplayback(w http.ResponseWriter, req *http.Request) { body := []byte{0x78, 0} // protobuf body request, err := http.NewRequest("POST", proxyURL.String(), bytes.NewReader(body)) + copyHeaders(req.Header, request.Header, false) + request.Header.Set("User-Agent", ua) if err != nil { log.Panic(err) } - copyHeaders(req.Header, request.Header, false) - - // https://github.com/iv-org/invidious-companion/blob/306f2d5f12440275e3202a52e8555eb88d9a34be/src/routes/videoPlaybackProxy.ts#L74-L83 - switch c { - case "ANDROID": - request.Header.Set("User-Agent", "com.google.android.youtube/1537338816 (Linux; U; Android 13; en_US; ; Build/TQ2A.230505.002; Cronet/113.0.5672.24)") - case "IOS": - request.Header.Set("User-Agent", "com.google.ios.youtube/19.32.8 (iPhone14,5; U; CPU iOS 17_6 like Mac OS X;)") - case "WEB": - request.Header.Set("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36") - default: - request.Header.Set("User-Agent", ua) - } resp, err := client.Do(request) if err != nil {