mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 13:36:09 +05:00
add set torrent, for set title,poster,data
This commit is contained in:
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
//Action: add, get, rem, list, drop
|
||||
//Action: add, get, set, rem, list, drop
|
||||
type torrReqJS struct {
|
||||
requestI
|
||||
Link string `json:"link,omitempty"`
|
||||
@@ -41,6 +41,10 @@ func torrents(c *gin.Context) {
|
||||
{
|
||||
getTorrent(req, c)
|
||||
}
|
||||
case "set":
|
||||
{
|
||||
setTorrent(req, c)
|
||||
}
|
||||
case "rem":
|
||||
{
|
||||
remTorrent(req, c)
|
||||
@@ -53,6 +57,7 @@ func torrents(c *gin.Context) {
|
||||
{
|
||||
dropTorrent(req, c)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,6 +112,15 @@ func getTorrent(req torrReqJS, c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
func setTorrent(req torrReqJS, c *gin.Context) {
|
||||
if req.Hash == "" {
|
||||
c.AbortWithError(http.StatusBadRequest, errors.New("hash is empty"))
|
||||
return
|
||||
}
|
||||
torr.SetTorrent(req.Hash, req.Title, req.Poster, req.Data)
|
||||
c.Status(200)
|
||||
}
|
||||
|
||||
func remTorrent(req torrReqJS, c *gin.Context) {
|
||||
if req.Hash == "" {
|
||||
c.AbortWithError(http.StatusBadRequest, errors.New("hash is empty"))
|
||||
|
||||
Reference in New Issue
Block a user