From 64ae3b8f1c211eeb39e0a5daee8d71de5fcafe90 Mon Sep 17 00:00:00 2001 From: nikk gitanes Date: Fri, 13 Oct 2023 17:38:41 +0300 Subject: [PATCH] also for stream --- server/web/api/m3u.go | 2 +- server/web/api/stream.go | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/server/web/api/m3u.go b/server/web/api/m3u.go index a5fc48c..22aa259 100644 --- a/server/web/api/m3u.go +++ b/server/web/api/m3u.go @@ -42,7 +42,6 @@ func allPlayList(c *gin.Context) { // http://127.0.0.1:8090/playlist?hash=...&fromlast // http://127.0.0.1:8090/playlist/fname?hash=... func playList(c *gin.Context) { - name := strings.ReplaceAll(c.Param("fname"), `/`, "") // strip starting / from param hash, _ := c.GetQuery("hash") _, fromlast := c.GetQuery("fromlast") if hash == "" { @@ -67,6 +66,7 @@ func playList(c *gin.Context) { host := utils.GetScheme(c) + "://" + c.Request.Host list := getM3uList(tor.Status(), host, fromlast) list = "#EXTM3U\n" + list + name := strings.ReplaceAll(c.Param("fname"), `/`, "") // strip starting / from param if name == "" { name = tor.Name() + ".m3u" } else { diff --git a/server/web/api/stream.go b/server/web/api/stream.go index b33f22b..28eef3b 100644 --- a/server/web/api/stream.go +++ b/server/web/api/stream.go @@ -4,6 +4,7 @@ import ( "net/http" "net/url" "strconv" + "strings" "server/torr" "server/torr/state" @@ -120,8 +121,14 @@ func stream(c *gin.Context) { } else // return m3u if query if m3u { + name := strings.ReplaceAll(c.Param("fname"), `/`, "") // strip starting / from param + if name == "" { + name = tor.Name() + ".m3u" + } else { + name += ".m3u" + } m3ulist := "#EXTM3U\n" + getM3uList(tor.Status(), utils2.GetScheme(c)+"://"+c.Request.Host, fromlast) - sendM3U(c, tor.Name()+".m3u", tor.Hash().HexString(), m3ulist) + sendM3U(c, name, tor.Hash().HexString(), m3ulist) return } else // return play if query