Compare commits

..

No commits in common. "f4d4f3075ead4b8620ecb63adc8fcc3a674c68da" and "5d16ff8424250f9951395850ec944efb63b45f3c" have entirely different histories.

3 changed files with 6 additions and 31 deletions

View File

@ -25,8 +25,6 @@ Usage of go-qbittorrent-sync:
Number of second to check new files to sync (default 30)
-qbittorrent-password string
Password of qbittorrent
-qbittorrent-password-file string
Password file with the password of qbittorrent
-qbittorrent-sync-tag string
Tag of qbittorrent to copy (default "Sync")
-qbittorrent-synced-tag string

16
main.go
View File

@ -1,10 +1,8 @@
package main
import (
"bytes"
"flag"
"log"
"os"
"time"
)
@ -15,7 +13,6 @@ func main() {
flag.StringVar(&qbitoptions.Uri, "qbittorrent-uri", "http://localhost:8080", "URI of qbittorrent")
flag.StringVar(&qbitoptions.Username, "qbittorrent-username", "", "Username of qbittorrent")
flag.StringVar(&qbitoptions.Password, "qbittorrent-password", "", "Password of qbittorrent")
flag.StringVar(&qbitoptions.PasswordFile, "qbittorrent-password-file", "", "Password file with the password of qbittorrent")
flag.StringVar(&qbitoptions.SyncTag, "qbittorrent-sync-tag", "Sync", "Tag of qbittorrent to copy")
flag.StringVar(&qbitoptions.SyncedTag, "qbittorrent-synced-tag", "", "Tag of qbittorrent when copy finished")
flag.StringVar(&rsyncoptions.Hostname, "rsync-hostname", "", "Rsync host")
@ -25,19 +22,6 @@ func main() {
flag.IntVar(&poolTime, "pool-time", 30, "Number of second to check new files to sync")
flag.Parse()
if qbitoptions.PasswordFile != "" {
var b []byte
var ok bool
var err error
if b, err = os.ReadFile(qbitoptions.PasswordFile); err != nil {
log.Fatalf("[Qbit] Reading password file failed: %v", err)
}
if b, ok = bytes.CutSuffix(b, []byte{'\r', '\n'}); !ok {
b, _ = bytes.CutSuffix(b, []byte{'\n'})
}
qbitoptions.Password = string(b)
}
if qbitoptions.Uri == "" ||
qbitoptions.Username == "" ||
qbitoptions.Password == "" ||

View File

@ -1,8 +1,6 @@
package main
import (
"bytes"
"errors"
"fmt"
"strings"
@ -10,12 +8,11 @@ import (
)
type QBitTorrentOptions struct {
Uri string
Username string
Password string
PasswordFile string
SyncTag string
SyncedTag string
Uri string
Username string
Password string
SyncTag string
SyncedTag string
}
type QBittorrentCli struct {
@ -35,7 +32,7 @@ type Torrent struct {
func NewQBittorrentCli(options *QBitTorrentOptions) (*QBittorrentCli, error) {
r := resty.New().SetBaseURL(fmt.Sprintf("%s/api/v2", options.Uri))
result, err := r.
_, err := r.
R().
SetFormData(map[string]string{
"username": options.Username,
@ -47,10 +44,6 @@ func NewQBittorrentCli(options *QBitTorrentOptions) (*QBittorrentCli, error) {
return nil, err
}
if !bytes.Equal(result.Body(), []byte("Ok.")) {
return nil, errors.New("auth failed")
}
cli := &QBittorrentCli{
SyncTag: options.SyncTag,
SyncedTag: options.SyncedTag,