mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 13:36:09 +05:00
fix m3u auth
This commit is contained in:
@@ -40,7 +40,7 @@ func stream(c *gin.Context) {
|
|||||||
data := ""
|
data := ""
|
||||||
notAuth := c.GetBool("not_auth")
|
notAuth := c.GetBool("not_auth")
|
||||||
|
|
||||||
if notAuth && play {
|
if notAuth && (play || m3u) {
|
||||||
streamNoAuth(c)
|
streamNoAuth(c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -134,6 +134,9 @@ func streamNoAuth(c *gin.Context) {
|
|||||||
link := c.Query("link")
|
link := c.Query("link")
|
||||||
indexStr := c.Query("index")
|
indexStr := c.Query("index")
|
||||||
_, preload := c.GetQuery("preload")
|
_, preload := c.GetQuery("preload")
|
||||||
|
_, m3u := c.GetQuery("m3u")
|
||||||
|
_, fromlast := c.GetQuery("fromlast")
|
||||||
|
_, play := c.GetQuery("play")
|
||||||
title := c.Query("title")
|
title := c.Query("title")
|
||||||
poster := c.Query("poster")
|
poster := c.Query("poster")
|
||||||
data := ""
|
data := ""
|
||||||
@@ -193,5 +196,18 @@ func streamNoAuth(c *gin.Context) {
|
|||||||
torr.Preload(tor, index)
|
torr.Preload(tor, index)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// return m3u if query
|
||||||
|
if m3u {
|
||||||
|
m3ulist := "#EXTM3U\n" + getM3uList(tor.Status(), "http://"+c.Request.Host, fromlast)
|
||||||
|
sendM3U(c, tor.Name()+".m3u", tor.Hash().HexString(), m3ulist)
|
||||||
|
return
|
||||||
|
} else
|
||||||
|
// return play if query
|
||||||
|
if play {
|
||||||
tor.Stream(index, c.Request, c.Writer)
|
tor.Stream(index, c.Request, c.Writer)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.Header("WWW-Authenticate", "Basic realm=Authorization Required")
|
||||||
|
c.AbortWithStatus(http.StatusUnauthorized)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ func BasicAuth(accounts gin.Accounts) gin.HandlerFunc {
|
|||||||
user, found := pairs.searchCredential(c.Request.Header.Get("Authorization"))
|
user, found := pairs.searchCredential(c.Request.Header.Get("Authorization"))
|
||||||
if !found {
|
if !found {
|
||||||
if strings.HasPrefix(c.FullPath(), "/stream") ||
|
if strings.HasPrefix(c.FullPath(), "/stream") ||
|
||||||
strings.HasPrefix(c.FullPath(), "/playlist") {
|
(strings.HasPrefix(c.FullPath(), "/playlist") && c.FullPath() != "/playlistall/all.m3u") {
|
||||||
c.Set("not_auth", true)
|
c.Set("not_auth", true)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user