mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 00:39:13 +00:00
Add support for using freeleech tokens if available
This commit is contained in:
parent
74f777340e
commit
1242c19883
21 changed files with 88 additions and 34 deletions
|
@ -23,7 +23,7 @@ import (
|
|||
const DefaultURL = "https://redacted.sh/ajax.php"
|
||||
|
||||
type ApiClient interface {
|
||||
GetTorrentByID(ctx context.Context, torrentID string) (*domain.TorrentBasic, error)
|
||||
GetTorrentByID(ctx context.Context, torrentID string, freeleechToken bool) (*domain.TorrentBasic, error)
|
||||
TestAPI(ctx context.Context) (bool, error)
|
||||
}
|
||||
|
||||
|
@ -214,7 +214,7 @@ func (c *Client) getJSON(ctx context.Context, params url.Values, data any) error
|
|||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) GetTorrentByID(ctx context.Context, torrentID string) (*domain.TorrentBasic, error) {
|
||||
func (c *Client) GetTorrentByID(ctx context.Context, torrentID string, freeleechToken bool) (*domain.TorrentBasic, error) {
|
||||
if torrentID == "" {
|
||||
return nil, errors.New("red client: must have torrentID")
|
||||
}
|
||||
|
@ -224,6 +224,9 @@ func (c *Client) GetTorrentByID(ctx context.Context, torrentID string) (*domain.
|
|||
params := url.Values{}
|
||||
params.Add("action", "torrent")
|
||||
params.Add("id", torrentID)
|
||||
if freeleechToken {
|
||||
params.Add("usetoken", "1")
|
||||
}
|
||||
|
||||
err := c.getJSON(ctx, params, &response)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue