Skip to content

Commit 3f0703a

Browse files
Fix playlist credentials on non Xtream playlist (#75)
Signed-off-by: Pierre-Emmanuel Jacquier <[email protected]>
1 parent a0dc24e commit 3f0703a

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

pkg/server/server.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"log"
2525
"net/url"
2626
"os"
27+
"path"
2728
"strings"
2829

2930
"github.com/jamesnetherton/m3u"
@@ -135,15 +136,17 @@ func (c *Config) replaceURL(uri string, xtream bool) (string, error) {
135136
protocol = "https"
136137
}
137138

138-
customEnd := c.CustomEndpoint
139+
customEnd := strings.Trim(c.CustomEndpoint, "/")
139140
if customEnd != "" {
140141
customEnd = fmt.Sprintf("/%s", customEnd)
141142
}
142143

143-
path := oriURL.EscapedPath()
144+
uriPath := oriURL.EscapedPath()
144145
if xtream {
145-
path = strings.ReplaceAll(path, c.XtreamUser.PathEscape(), c.User.PathEscape())
146-
path = strings.ReplaceAll(path, c.XtreamPassword.PathEscape(), c.Password.PathEscape())
146+
uriPath = strings.ReplaceAll(uriPath, c.XtreamUser.PathEscape(), c.User.PathEscape())
147+
uriPath = strings.ReplaceAll(uriPath, c.XtreamPassword.PathEscape(), c.Password.PathEscape())
148+
} else {
149+
uriPath = path.Join("/", c.User.PathEscape(), c.Password.PathEscape(), uriPath)
147150
}
148151

149152
basicAuth := oriURL.User.String()
@@ -158,7 +161,7 @@ func (c *Config) replaceURL(uri string, xtream bool) (string, error) {
158161
c.HostConfig.Hostname,
159162
c.HostConfig.Port,
160163
customEnd,
161-
path,
164+
uriPath,
162165
)
163166

164167
newURL, err := url.Parse(newURI)

0 commit comments

Comments
 (0)