From 1aae436c30f3fb3539a254b435fe23abc8f34acb Mon Sep 17 00:00:00 2001 From: YouROK <8yourok8@mail.ru> Date: Wed, 24 Mar 2021 15:31:43 +0300 Subject: [PATCH] remove title from fname --- server/web/api/stream.go | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/server/web/api/stream.go b/server/web/api/stream.go index 453806b..803aef4 100644 --- a/server/web/api/stream.go +++ b/server/web/api/stream.go @@ -72,12 +72,6 @@ func stream(c *gin.Context) { 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) @@ -90,6 +84,10 @@ func stream(c *gin.Context) { return } + if tor.Title == "" { + tor.Title = tor.Name() + } + // save to db if save { torr.SaveTorrentToDB(tor) @@ -169,12 +167,6 @@ func streamNoAuth(c *gin.Context) { 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) @@ -187,6 +179,10 @@ func streamNoAuth(c *gin.Context) { return } + if tor.Title == "" { + tor.Title = tor.Name() + } + // find file index := -1 if len(tor.Files()) == 1 {