mirror of
https://github.com/simon-ding/polaris.git
synced 2026-04-21 03:07:30 +08:00
feat: add qbit category
This commit is contained in:
@@ -11,6 +11,8 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
const btCategory = "polaris"
|
||||
|
||||
type Info struct {
|
||||
URL string
|
||||
User string
|
||||
@@ -18,7 +20,8 @@ type Info struct {
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
c *qbt.Client
|
||||
c *qbt.Client
|
||||
category string
|
||||
Info
|
||||
}
|
||||
|
||||
@@ -36,11 +39,11 @@ func NewClient(url, user, pass string) (*Client, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Client{c: qb, Info: Info{URL: url, User: user, Password: pass}}, nil
|
||||
return &Client{c: qb, category: btCategory, Info: Info{URL: url, User: user, Password: pass}}, nil
|
||||
}
|
||||
|
||||
func (c *Client) GetAll() ([]pkg.Torrent, error) {
|
||||
tt, err := c.c.Torrents(qbt.TorrentsOptions{})
|
||||
tt, err := c.c.Torrents(qbt.TorrentsOptions{Category: &c.category})
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "get torrents")
|
||||
}
|
||||
@@ -66,7 +69,7 @@ func (c *Client) Download(link, dir string) (pkg.Torrent, error) {
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "get hash")
|
||||
}
|
||||
err = c.c.DownloadLinks([]string{magnet}, qbt.DownloadOptions{Savepath: &dir})
|
||||
err = c.c.DownloadLinks([]string{magnet}, qbt.DownloadOptions{Savepath: &dir, Category: &c.category})
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "qbt download")
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ func (s *Server) Serve() error {
|
||||
activity.GET("/", HttpHandler(s.GetAllActivities))
|
||||
activity.POST("/delete", HttpHandler(s.RemoveActivity))
|
||||
activity.GET("/media/:id", HttpHandler(s.GetMediaDownloadHistory))
|
||||
activity.GET("/torrents", HttpHandler(s.GetAllTorrents))
|
||||
//activity.GET("/torrents", HttpHandler(s.GetAllTorrents))
|
||||
}
|
||||
|
||||
tv := api.Group("/media")
|
||||
|
||||
Reference in New Issue
Block a user