mirror of
https://github.com/celogeek/go-qbittorrent-sync.git
synced 2025-05-24 07:52:36 +02:00
threat forbidden as an error
This commit is contained in:
parent
2c197e2208
commit
600de44787
3
main.go
3
main.go
@ -64,6 +64,9 @@ func main() {
|
||||
torrents, err := qcli.List()
|
||||
if err != nil {
|
||||
log.Printf("[QBit] List Error: %v", err)
|
||||
if err.Error() == "forbidden" {
|
||||
log.Fatal("Need to authenticate again. Exiting ...")
|
||||
}
|
||||
}
|
||||
if len(torrents) > 0 {
|
||||
log.Printf("[QBit] Found %d torrents to sync", len(torrents))
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/go-resty/resty/v2"
|
||||
@ -34,6 +35,12 @@ type Torrent struct {
|
||||
|
||||
func NewQBittorrentCli(options *QBitTorrentOptions) (*QBittorrentCli, error) {
|
||||
r := resty.New().SetBaseURL(fmt.Sprintf("%s/api/v2", options.Uri))
|
||||
r.OnAfterResponse(func(c *resty.Client, r *resty.Response) error {
|
||||
if r.StatusCode() == http.StatusForbidden {
|
||||
return errors.New("forbidden")
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
result, err := r.
|
||||
R().
|
||||
|
Loading…
x
Reference in New Issue
Block a user