add rutor api

This commit is contained in:
YouROK
2023-01-29 20:04:48 +03:00
parent fbd1765331
commit ff1c05a6bf
6 changed files with 22 additions and 1 deletions

View File

@@ -39,6 +39,7 @@ func SetupRoute(route *gin.RouterGroup) {
route.GET("/playlist/*fname", playList)
route.GET("/download/:size", download)
route.GET("/search/*query", rutorSearch)
}
func shutdown(c *gin.Context) {

View File

@@ -2,6 +2,7 @@ package api
import (
"net/http"
"server/rutor"
"github.com/gin-gonic/gin"
"github.com/pkg/errors"
@@ -11,7 +12,7 @@ import (
"server/torr"
)
//Action: get, set, def
// Action: get, set, def
type setsReqJS struct {
requestI
Sets *sets.BTSets `json:"sets,omitempty"`
@@ -34,11 +35,14 @@ func settings(c *gin.Context) {
if req.Sets.EnableDLNA {
dlna.Start()
}
rutor.Stop()
rutor.Start()
c.Status(200)
return
} else if req.Action == "def" {
torr.SetDefSettings()
dlna.Stop()
rutor.Stop()
c.Status(200)
return
}

View File

@@ -2,6 +2,7 @@ package web
import (
"net"
"server/rutor"
"sort"
"github.com/gin-contrib/cors"
@@ -37,6 +38,8 @@ func Start(port string) {
waitChan <- err
return
}
rutor.Start()
gin.SetMode(gin.ReleaseMode)
//corsCfg := cors.DefaultConfig()