From 301e553e807a1e94c199c1b1ffff9d1822c809b8 Mon Sep 17 00:00:00 2001 From: TimIsOverpowered Date: Sun, 28 Jul 2024 21:35:30 -0500 Subject: [PATCH] changed path name --- api/streams.go | 3 ++- server/gin.go | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/api/streams.go b/api/streams.go index 51e4303..eeb490e 100644 --- a/api/streams.go +++ b/api/streams.go @@ -11,7 +11,8 @@ import ( type Stream struct { Created_at string `json:"createdAt"` User struct { - Username string `json:"username"` + Username string `json:"username"` + StreamKey string `json:"stream_key"` } `json:"user"` Ingest struct { Server string `json:"server"` diff --git a/server/gin.go b/server/gin.go index 7f41404..1e0f79a 100644 --- a/server/gin.go +++ b/server/gin.go @@ -128,7 +128,7 @@ func Initalize() { } fullEndUrl := strings.Replace(c.Param("endUrl"), "index", "stream", 1) + "?" + c.Request.URL.Query().Encode() - mediamtxEndUrl := "https://" + utils.Config.IngestAPI.Username + ":" + utils.Config.IngestAPI.Password + "@" + streamData.Ingest.Server + ".angelthump.com/hls/live/" + streamData.User.Username + "/" + fullEndUrl + mediamtxEndUrl := "https://" + utils.Config.IngestAPI.Username + ":" + utils.Config.IngestAPI.Password + "@" + streamData.Ingest.Server + ".angelthump.com/hls/live/" + streamData.User.StreamKey + "/" + fullEndUrl restyClient := resty.New() resp, _ := restyClient.R(). @@ -147,6 +147,7 @@ func Initalize() { client.Rdb.Set(client.Ctx, key, resp.Body(), 20*time.Second) c.Data(200, "video/mp2t", []byte(resp.Body())) } else if strings.HasSuffix(endUrl, "init.mp4") { + client.Rdb.Set(client.Ctx, key, resp.Body(), 24*time.Hour) c.Data(200, "video/mp4", []byte(resp.Body())) } else if strings.HasSuffix(endUrl, ".mp4") { client.Rdb.Set(client.Ctx, key, resp.Body(), 20*time.Second) @@ -155,6 +156,7 @@ func Initalize() { client.Rdb.Set(client.Ctx, key, resp.Body(), 20*time.Second) c.Data(200, "video/mp4", []byte(resp.Body())) } else if strings.HasSuffix(endUrl, ".m3u8") { + client.Rdb.Set(client.Ctx, key, resp.Body(), 1*time.Second) c.Data(200, "application/x-mpegURL", []byte(resp.Body())) } else { c.AbortWithStatus(400)