forked from YouROK/TorrServer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rutor.go
38 lines (34 loc) · 831 Bytes
/
rutor.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package api
import (
"net/http"
"net/url"
"github.com/gin-gonic/gin"
"github.com/Terisback/TorrServer/server/rutor"
"github.com/Terisback/TorrServer/server/rutor/models"
sets "github.com/Terisback/TorrServer/server/settings"
)
// rutorSearch godoc
//
// @Summary Makes a rutor search
// @Description Makes a rutor search.
//
// @Tags API
//
// @Param query query string true "Rutor query"
//
// @Produce json
// @Success 200 {array} models.TorrentDetails "Rutor torrent search result(s)"
// @Router /search [get]
func rutorSearch(c *gin.Context) {
if !sets.BTsets.EnableRutorSearch {
c.JSON(http.StatusBadRequest, []string{})
return
}
query := c.Query("query")
query, _ = url.QueryUnescape(query)
list := rutor.Search(query)
if list == nil {
list = []*models.TorrentDetails{}
}
c.JSON(200, list)
}