From 1e7228550bf62ee48eb1758e4ce255061c214c6f Mon Sep 17 00:00:00 2001 From: nikk gitanes Date: Tue, 31 Oct 2023 02:33:46 +0300 Subject: [PATCH] add m3u8 check in fname and handle missing fname in streamNoAuth also --- server/web/api/m3u.go | 2 +- server/web/api/stream.go | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/server/web/api/m3u.go b/server/web/api/m3u.go index 22aa259..6952ba5 100644 --- a/server/web/api/m3u.go +++ b/server/web/api/m3u.go @@ -69,7 +69,7 @@ func playList(c *gin.Context) { name := strings.ReplaceAll(c.Param("fname"), `/`, "") // strip starting / from param if name == "" { name = tor.Name() + ".m3u" - } else { + } else if !strings.HasSuffix(strings.ToLower(name), ".m3u") && !strings.HasSuffix(strings.ToLower(name), ".m3u8") { name += ".m3u" } diff --git a/server/web/api/stream.go b/server/web/api/stream.go index 575a93b..c8fcce2 100644 --- a/server/web/api/stream.go +++ b/server/web/api/stream.go @@ -124,7 +124,7 @@ func stream(c *gin.Context) { name := strings.ReplaceAll(c.Param("fname"), `/`, "") // strip starting / from param if name == "" { name = tor.Name() + ".m3u" - } else if !strings.HasSuffix(strings.ToLower(name), ".m3u") { + } else if !strings.HasSuffix(strings.ToLower(name), ".m3u") && !strings.HasSuffix(strings.ToLower(name), ".m3u8") { name += ".m3u" } m3ulist := "#EXTM3U\n" + getM3uList(tor.Status(), utils2.GetScheme(c)+"://"+c.Request.Host, fromlast) @@ -207,8 +207,14 @@ func streamNoAuth(c *gin.Context) { // return m3u if query if m3u { + name := strings.ReplaceAll(c.Param("fname"), `/`, "") // strip starting / from param + if name == "" { + name = tor.Name() + ".m3u" + } else if !strings.HasSuffix(strings.ToLower(name), ".m3u") && !strings.HasSuffix(strings.ToLower(name), ".m3u8") { + 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