From 1e0dc9edcb5879e127ffcfa02059d1a3b4711030 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Jacquier <15922119+pierre-emmanuelJ@users.noreply.github.com> Date: Thu, 31 Mar 2022 11:05:58 +0200 Subject: [PATCH] Xtream-API: Add /play url support (#118) Signed-off-by: Pierre-Emmanuel Jacquier <15922119+pierre-emmanuelJ@users.noreply.github.com> --- pkg/server/routes.go | 1 + pkg/server/xtreamHandles.go | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/pkg/server/routes.go b/pkg/server/routes.go index 5b321ec7..ad54e68e 100644 --- a/pkg/server/routes.go +++ b/pkg/server/routes.go @@ -65,6 +65,7 @@ func (c *Config) xtreamRoutes(r *gin.RouterGroup) { r.GET(fmt.Sprintf("/series/%s/%s/:id", c.User, c.Password), c.xtreamStreamSeries) r.GET(fmt.Sprintf("/hlsr/:token/%s/%s/:channel/:hash/:chunk", c.User, c.Password), c.xtreamHlsrStream) r.GET("/hls/:token/:chunk", c.xtreamHlsStream) + r.GET("/play/:token/:type", c.xtreamStreamPlay) } func (c *Config) m3uRoutes(r *gin.RouterGroup) { diff --git a/pkg/server/xtreamHandles.go b/pkg/server/xtreamHandles.go index b7d22292..f8ac670f 100644 --- a/pkg/server/xtreamHandles.go +++ b/pkg/server/xtreamHandles.go @@ -312,6 +312,18 @@ func (c *Config) xtreamStreamLive(ctx *gin.Context) { c.xtreamStream(ctx, rpURL) } +func (c *Config) xtreamStreamPlay(ctx *gin.Context) { + token := ctx.Param("token") + t := ctx.Param("type") + rpURL, err := url.Parse(fmt.Sprintf("%s/play/%s/%s", c.XtreamBaseURL, token, t)) + if err != nil { + ctx.AbortWithError(http.StatusInternalServerError, err) // nolint: errcheck + return + } + + c.xtreamStream(ctx, rpURL) +} + func (c *Config) xtreamStreamTimeshift(ctx *gin.Context) { duration := ctx.Param("duration") start := ctx.Param("start")