mirror of
https://github.com/pierre-emmanuelJ/iptv-proxy.git
synced 2026-03-24 09:54:27 +01:00
fix hls header
Signed-off-by: Pierre-Emmanuel Jacquier <15922119+pierre-emmanuelJ@users.noreply.github.com>
This commit is contained in:
@@ -58,7 +58,6 @@ func (c *Config) xtreamRoutes(r *gin.RouterGroup) {
|
||||
r.GET(fmt.Sprintf("/movie/%s/%s/:id", c.User, c.Password), c.xtreamStreamMovie)
|
||||
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/:id", c.xtreamHlsStream)
|
||||
}
|
||||
|
||||
func (c *Config) m3uRoutes(r *gin.RouterGroup) {
|
||||
|
||||
@@ -287,7 +287,7 @@ func (c *Config) hlsXtreamStream(ctx *gin.Context, oriURL *url.URL) {
|
||||
return
|
||||
}
|
||||
|
||||
req.Header.Set("User-Agent", ctx.Request.UserAgent())
|
||||
copyHttpHeader(req.Header, ctx.Request.Header)
|
||||
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
@@ -314,7 +314,7 @@ func (c *Config) hlsXtreamStream(ctx *gin.Context, oriURL *url.URL) {
|
||||
return
|
||||
}
|
||||
|
||||
hlsReq.Header.Set("User-Agent", ctx.Request.UserAgent())
|
||||
copyHttpHeader(hlsReq.Header, ctx.Request.Header)
|
||||
|
||||
hlsResp, err := client.Do(hlsReq)
|
||||
if err != nil {
|
||||
@@ -330,6 +330,9 @@ func (c *Config) hlsXtreamStream(ctx *gin.Context, oriURL *url.URL) {
|
||||
}
|
||||
body := string(b)
|
||||
body = strings.ReplaceAll(body, "/"+c.XtreamUser.String()+"/"+c.XtreamPassword.String()+"/", "/"+c.User.String()+"/"+c.Password.String()+"/")
|
||||
|
||||
copyHttpHeader(ctx.Request.Header, hlsResp.Header)
|
||||
|
||||
ctx.Data(http.StatusOK, hlsResp.Header.Get("Content-Type"), []byte(body))
|
||||
return
|
||||
}
|
||||
@@ -339,16 +342,3 @@ func (c *Config) hlsXtreamStream(ctx *gin.Context, oriURL *url.URL) {
|
||||
|
||||
ctx.Status(resp.StatusCode)
|
||||
}
|
||||
|
||||
func (c *Config) xtreamHlsStream(ctx *gin.Context) {
|
||||
id := ctx.Param("id")
|
||||
token := ctx.Param("token")
|
||||
|
||||
rpURL, err := url.Parse(fmt.Sprintf("%s/hls/%s/%s", c.XtreamBaseURL, token, id))
|
||||
if err != nil {
|
||||
ctx.AbortWithError(http.StatusInternalServerError, err) // nolint: errcheck
|
||||
return
|
||||
}
|
||||
|
||||
c.stream(ctx, rpURL)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user