Merge branch 'master' into old-engine

This commit is contained in:
nikk gitanes
2023-10-31 05:06:34 +03:00
4 changed files with 48 additions and 16 deletions

View File

@@ -40,6 +40,7 @@ func allPlayList(c *gin.Context) {
// http://127.0.0.1:8090/playlist?hash=...
// http://127.0.0.1:8090/playlist?hash=...&fromlast
// http://127.0.0.1:8090/playlist/fname?hash=...
func playList(c *gin.Context) {
hash, _ := c.GetQuery("hash")
_, fromlast := c.GetQuery("fromlast")
@@ -65,8 +66,14 @@ 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 if !strings.HasSuffix(strings.ToLower(name), ".m3u") && !strings.HasSuffix(strings.ToLower(name), ".m3u8") {
name += ".m3u"
}
sendM3U(c, tor.Name()+".m3u", tor.Hash().HexString(), list)
sendM3U(c, name, tor.Hash().HexString(), list)
}
func sendM3U(c *gin.Context, name, hash string, m3u string) {

View File

@@ -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 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
@@ -200,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