From 785e38ea293aaeaf123acc115d9c0501443bf0b5 Mon Sep 17 00:00:00 2001 From: dragongoose Date: Fri, 2 Jun 2023 08:13:56 -0400 Subject: [PATCH] New stream endpoint --- routes/proxy/proxy.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/routes/proxy/proxy.go b/routes/proxy/proxy.go index 225dbc5..d35361d 100644 --- a/routes/proxy/proxy.go +++ b/routes/proxy/proxy.go @@ -42,4 +42,38 @@ func Routes(route *gin.Engine) { context.Data(200, "application/text", []byte(playlistFile)) }) + + auth.GET("/stream/sub/:encodedUrl", func(context *gin.Context) { + decodedUrl, err := b64.StdEncoding.DecodeString(context.Param("encodedUrl")) + if err != nil { + context.Error(err) + } + + playlistFile, err := twitch.GetSubPlaylist(string(decodedUrl)) + if err != nil { + context.Error(err) + } + + context.Data(200, "application/text", []byte(playlistFile)) + }) + + auth.GET("/stream/segment/:encodedUrl", func(context *gin.Context) { + decodedUrl, err := b64.StdEncoding.DecodeString(context.Param("encodedUrl")) + if err != nil { + context.Error(err) + } + + segmentData, err := http.Get(string(decodedUrl)) + if err != nil { + context.Error(err) + return + } + + segment, err := io.ReadAll(segmentData.Body) + if err != nil { + context.Error(err) + } + + context.Data(200, "fuck", segment) + }) }