mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-21 06:26:10 +05:00
update
This commit is contained in:
@@ -27,5 +27,5 @@ func SetupRoute(route *gin.Engine) {
|
||||
}
|
||||
|
||||
func echo(c *gin.Context) {
|
||||
c.String(200, "{\"version\": \"%v\"}", version.Version)
|
||||
c.String(200, "%v", version.Version)
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/pkg/errors"
|
||||
sets "server/settings"
|
||||
"server/torr"
|
||||
)
|
||||
|
||||
//Action: get, set
|
||||
@@ -27,7 +28,7 @@ func settings(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
if req.Action == "set" {
|
||||
sets.SetBTSets(req.Sets)
|
||||
torr.SetSettings(req.Sets)
|
||||
c.Status(200)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -65,6 +65,11 @@ func stream(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if !tor.GotInfo() {
|
||||
c.AbortWithError(http.StatusInternalServerError, errors.New("timeout connection torrent"))
|
||||
return
|
||||
}
|
||||
|
||||
// save to db
|
||||
if save {
|
||||
torr.SaveTorrentToDB(tor)
|
||||
|
||||
@@ -75,12 +75,18 @@ func addTorrent(req torrReqJS, c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if req.SaveToDB {
|
||||
torr.SaveTorrentToDB(tor)
|
||||
}
|
||||
go func() {
|
||||
if !tor.GotInfo() {
|
||||
log.TLogln("error add torrent:", "timeout connection torrent")
|
||||
return
|
||||
}
|
||||
|
||||
st := tor.Status()
|
||||
c.JSON(200, st)
|
||||
if req.SaveToDB {
|
||||
torr.SaveTorrentToDB(tor)
|
||||
}
|
||||
}()
|
||||
|
||||
c.JSON(200, tor.Status())
|
||||
}
|
||||
|
||||
func getTorrent(req torrReqJS, c *gin.Context) {
|
||||
@@ -109,6 +115,10 @@ func remTorrent(req torrReqJS, c *gin.Context) {
|
||||
|
||||
func listTorrent(req torrReqJS, c *gin.Context) {
|
||||
list := torr.ListTorrent()
|
||||
if list == nil {
|
||||
c.Status(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
var stats []*state.TorrentStatus
|
||||
for _, tr := range list {
|
||||
stats = append(stats, tr.Status())
|
||||
|
||||
Reference in New Issue
Block a user