update auth

This commit is contained in:
YouROK
2021-03-11 15:17:58 +03:00
parent 001faf7a97
commit 5eaa673149

View File

@@ -138,6 +138,7 @@ func streamNoAuth(c *gin.Context) {
_, preload := c.GetQuery("preload") _, preload := c.GetQuery("preload")
title := c.Query("title") title := c.Query("title")
poster := c.Query("poster") poster := c.Query("poster")
data := ""
if link == "" { if link == "" {
c.AbortWithError(http.StatusBadRequest, errors.New("link should not be empty")) c.AbortWithError(http.StatusBadRequest, errors.New("link should not be empty"))
@@ -162,9 +163,23 @@ func streamNoAuth(c *gin.Context) {
} }
tor := torr.GetTorrent(spec.InfoHash.HexString()) tor := torr.GetTorrent(spec.InfoHash.HexString())
if tor == nil { if tor != nil {
c.AbortWithError(http.StatusNotFound, errors.New("Torrent not found")) title = tor.Title
return poster = tor.Poster
data = tor.Data
}
if tor == nil || tor.Stat == state.TorrentInDB {
if title == "" {
title = c.Param("fname")
title, _ = url.PathUnescape(title)
title = strings.TrimLeft(title, "/")
}
tor, err = torr.AddTorrent(spec, title, poster, data)
if err != nil {
c.AbortWithError(http.StatusInternalServerError, err)
return
}
} }
if !tor.GotInfo() { if !tor.GotInfo() {