From 3f0703a5630a4a0f1659f92197719287bc282ed0 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Jacquier <15922119+pierre-emmanuelJ@users.noreply.github.com> Date: Thu, 18 Mar 2021 17:41:39 +0100 Subject: [PATCH] Fix playlist credentials on non Xtream playlist (#75) Signed-off-by: Pierre-Emmanuel Jacquier <15922119+pierre-emmanuelJ@users.noreply.github.com> --- pkg/server/server.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pkg/server/server.go b/pkg/server/server.go index 8d591d4..bfbbf7b 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -24,6 +24,7 @@ import ( "log" "net/url" "os" + "path" "strings" "github.com/jamesnetherton/m3u" @@ -135,15 +136,17 @@ func (c *Config) replaceURL(uri string, xtream bool) (string, error) { protocol = "https" } - customEnd := c.CustomEndpoint + customEnd := strings.Trim(c.CustomEndpoint, "/") if customEnd != "" { customEnd = fmt.Sprintf("/%s", customEnd) } - path := oriURL.EscapedPath() + uriPath := oriURL.EscapedPath() if xtream { - path = strings.ReplaceAll(path, c.XtreamUser.PathEscape(), c.User.PathEscape()) - path = strings.ReplaceAll(path, c.XtreamPassword.PathEscape(), c.Password.PathEscape()) + uriPath = strings.ReplaceAll(uriPath, c.XtreamUser.PathEscape(), c.User.PathEscape()) + uriPath = strings.ReplaceAll(uriPath, c.XtreamPassword.PathEscape(), c.Password.PathEscape()) + } else { + uriPath = path.Join("/", c.User.PathEscape(), c.Password.PathEscape(), uriPath) } basicAuth := oriURL.User.String() @@ -158,7 +161,7 @@ func (c *Config) replaceURL(uri string, xtream bool) (string, error) { c.HostConfig.Hostname, c.HostConfig.Port, customEnd, - path, + uriPath, ) newURL, err := url.Parse(newURI)