From 03a37009c469bd95f92f3208da28e4418e6d6e5a Mon Sep 17 00:00:00 2001 From: Fijxu Date: Mon, 16 Dec 2024 02:34:09 -0300 Subject: [PATCH] =?UTF-8?q?handle=20user-agent=20header=20based=20on=20=1B?= =?UTF-8?q?[H=1B[2J=1B[3J=20query=20param?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- httppaths.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/httppaths.go b/httppaths.go index 8dac3fe..32139ff 100644 --- a/httppaths.go +++ b/httppaths.go @@ -38,6 +38,7 @@ func videoplayback(w http.ResponseWriter, req *http.Request) { } host := q.Get("host") + c := q.Get("c") q.Del("host") if len(host) <= 0 { @@ -95,11 +96,21 @@ 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) + + 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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36") + default: + request.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36") + } resp, err := client.Do(request) if err != nil {