Revert "use invidious-companion ways of adding headers and queries"
All checks were successful
CI / build (push) Successful in 4m31s

Not dealing with this shit now

This reverts commit 82185f4a28.
This commit is contained in:
Fijxu 2024-12-13 18:52:29 -03:00
parent 82185f4a28
commit 08e8607f5f
Signed by: Fijxu
GPG key ID: 32C1DDF333EDA6A4

View file

@ -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 {