Skip to content

Take control over your live stream video by running it yourself. Streaming + chat out of the box.

Fix base path string parsing

Gabe Kangasa55e5ccce983
diff --git a/s3Storage.go b/s3Storage.go
index fffae537b6..be21a24d0d 100644
--- a/s3Storage.go
+++ b/s3Storage.go
@@ -5,7 +5,6 @@ import (
"fmt"
"net/url"
"os"
- "path"
"strings"
log "github.com/sirupsen/logrus"
@@ -65,10 +64,12 @@ func (s *S3Storage) Save(filePath string) string {
fmt.Println(err)
}
+ // The following is a bit of a hack to take the location URL string of that file
+ // and get just the base URL without the file from it.
pathComponents := strings.Split(url.Path, "/")
pathComponents[len(pathComponents)-1] = ""
-
- s.host = fmt.Sprintf("%s://%s/%s", url.Scheme, url.Host, strings.Join(pathComponents, "/"))
+ pathString := strings.Join(pathComponents, "/")
+ s.host = fmt.Sprintf("%s://%s%s", url.Scheme, url.Host, pathString)
}
// fmt.Println("Uploaded", filePath, "to", response.Location)
@@ -77,20 +78,27 @@ func (s *S3Storage) Save(filePath string) string {
}
func (s *S3Storage) GenerateRemotePlaylist(playlist string, segments map[string]string) string {
+ baseHost, err := url.Parse(s.host)
+ baseHostComponents := []string{baseHost.Scheme + "://", baseHost.Host, baseHost.Path}
+
+ verifyError(err)
+
+ // baseHostString := fmt.Sprintf("%s://%s/%s", baseHost.Scheme, baseHost.Hostname, baseHost.Path)
+
var newPlaylist = ""
scanner := bufio.NewScanner(strings.NewReader(playlist))
for scanner.Scan() {
line := scanner.Text()
if line[0:1] != "#" {
- line = path.Join(s.host, line)
+ urlComponents := baseHostComponents
+ urlComponents = append(urlComponents, line)
+ line = strings.Join(urlComponents, "") //path.Join(s.host, line)
}
newPlaylist = newPlaylist + line + "\n"
}
- // fmt.Println(newPlaylist)
-
return newPlaylist
}