mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
add scheme to list
This commit is contained in:
14
server/utils/location.go
Normal file
14
server/utils/location.go
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
package utils
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gin-contrib/location"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetScheme(c *gin.Context) string {
|
||||||
|
url := location.Get(c)
|
||||||
|
if url == nil {
|
||||||
|
return "http"
|
||||||
|
}
|
||||||
|
return url.Scheme
|
||||||
|
}
|
||||||
@@ -10,13 +10,13 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/anacrolix/missinggo/httptoo"
|
||||||
|
|
||||||
sets "server/settings"
|
sets "server/settings"
|
||||||
"server/torr"
|
"server/torr"
|
||||||
"server/torr/state"
|
"server/torr/state"
|
||||||
"server/utils"
|
"server/utils"
|
||||||
|
|
||||||
"github.com/anacrolix/missinggo/httptoo"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
@@ -24,7 +24,7 @@ import (
|
|||||||
func allPlayList(c *gin.Context) {
|
func allPlayList(c *gin.Context) {
|
||||||
torrs := torr.ListTorrent()
|
torrs := torr.ListTorrent()
|
||||||
|
|
||||||
host := "http://" + c.Request.Host
|
host := utils.GetScheme(c) + "://" + c.Request.Host
|
||||||
list := "#EXTM3U\n"
|
list := "#EXTM3U\n"
|
||||||
hash := ""
|
hash := ""
|
||||||
// fn=file.m3u fix forkplayer bug with end .m3u in link
|
// fn=file.m3u fix forkplayer bug with end .m3u in link
|
||||||
@@ -61,7 +61,7 @@ func playList(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
host := "http://" + c.Request.Host
|
host := utils.GetScheme(c) + "://" + c.Request.Host
|
||||||
list := getM3uList(tor.Status(), host, fromlast)
|
list := getM3uList(tor.Status(), host, fromlast)
|
||||||
list = "#EXTM3U\n" + list
|
list = "#EXTM3U\n" + list
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
|
|
||||||
"server/torr"
|
"server/torr"
|
||||||
"server/torr/state"
|
"server/torr/state"
|
||||||
|
utils2 "server/utils"
|
||||||
"server/web/api/utils"
|
"server/web/api/utils"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -119,7 +120,7 @@ func stream(c *gin.Context) {
|
|||||||
} else
|
} else
|
||||||
// return m3u if query
|
// return m3u if query
|
||||||
if m3u {
|
if m3u {
|
||||||
m3ulist := "#EXTM3U\n" + getM3uList(tor.Status(), "http://"+c.Request.Host, fromlast)
|
m3ulist := "#EXTM3U\n" + getM3uList(tor.Status(), utils2.GetScheme(c)+"://"+c.Request.Host, fromlast)
|
||||||
sendM3U(c, tor.Name()+".m3u", tor.Hash().HexString(), m3ulist)
|
sendM3U(c, tor.Name()+".m3u", tor.Hash().HexString(), m3ulist)
|
||||||
return
|
return
|
||||||
} else
|
} else
|
||||||
@@ -199,7 +200,7 @@ func streamNoAuth(c *gin.Context) {
|
|||||||
|
|
||||||
// return m3u if query
|
// return m3u if query
|
||||||
if m3u {
|
if m3u {
|
||||||
m3ulist := "#EXTM3U\n" + getM3uList(tor.Status(), "http://"+c.Request.Host, fromlast)
|
m3ulist := "#EXTM3U\n" + getM3uList(tor.Status(), utils2.GetScheme(c)+"://"+c.Request.Host, fromlast)
|
||||||
sendM3U(c, tor.Name()+".m3u", tor.Hash().HexString(), m3ulist)
|
sendM3U(c, tor.Name()+".m3u", tor.Hash().HexString(), m3ulist)
|
||||||
return
|
return
|
||||||
} else
|
} else
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/gin-contrib/cors"
|
"github.com/gin-contrib/cors"
|
||||||
|
"github.com/gin-contrib/location"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
|
||||||
"server/log"
|
"server/log"
|
||||||
@@ -38,7 +39,7 @@ func Start(port string) {
|
|||||||
corsCfg.AllowHeaders = []string{"Origin", "Content-Length", "Content-Type", "X-Requested-With", "Accept", "Authorization"}
|
corsCfg.AllowHeaders = []string{"Origin", "Content-Length", "Content-Type", "X-Requested-With", "Accept", "Authorization"}
|
||||||
|
|
||||||
route := gin.New()
|
route := gin.New()
|
||||||
route.Use(log.WebLogger(), blocker.Blocker(), gin.Recovery(), cors.New(corsCfg))
|
route.Use(log.WebLogger(), blocker.Blocker(), gin.Recovery(), cors.New(corsCfg), location.Default())
|
||||||
|
|
||||||
route.GET("/echo", echo)
|
route.GET("/echo", echo)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user