mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 08:49:13 +00:00
feat(actions): qbit add options content layout and skip hash check (#393)
* feat(actions): qbit content layout and skip hash check * feat(actions): qbit options
This commit is contained in:
parent
db9d048f5d
commit
9508cbb46c
13 changed files with 394 additions and 50 deletions
|
@ -2,7 +2,6 @@ package action
|
|||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -102,10 +101,23 @@ func (s *service) qbittorrent(action domain.Action, release domain.Release) ([]s
|
|||
|
||||
func (s *service) prepareQbitOptions(action domain.Action, m domain.Macro) (map[string]string, error) {
|
||||
|
||||
options := map[string]string{}
|
||||
opts := &qbittorrent.TorrentAddOptions{}
|
||||
|
||||
if action.Paused {
|
||||
options["paused"] = "true"
|
||||
opts.Paused = BoolPointer(true)
|
||||
}
|
||||
if action.SkipHashCheck {
|
||||
opts.SkipHashCheck = BoolPointer(true)
|
||||
}
|
||||
if action.ContentLayout != "" {
|
||||
if action.ContentLayout == domain.ActionContentLayoutSubfolderCreate {
|
||||
layout := qbittorrent.ContentLayoutSubfolderCreate
|
||||
opts.ContentLayout = &layout
|
||||
} else if action.ContentLayout == domain.ActionContentLayoutSubfolderNone {
|
||||
layout := qbittorrent.ContentLayoutSubfolderNone
|
||||
opts.ContentLayout = &layout
|
||||
}
|
||||
// if ORIGINAL then leave empty
|
||||
}
|
||||
if action.SavePath != "" {
|
||||
// parse and replace values in argument string before continuing
|
||||
|
@ -114,8 +126,8 @@ func (s *service) prepareQbitOptions(action domain.Action, m domain.Macro) (map[
|
|||
return nil, errors.Wrap(err, "could not parse savepath macro: %v", action.SavePath)
|
||||
}
|
||||
|
||||
options["savepath"] = actionArgs
|
||||
options["autoTMM"] = "false"
|
||||
opts.SavePath = &actionArgs
|
||||
opts.AutoTMM = BoolPointer(false)
|
||||
}
|
||||
if action.Category != "" {
|
||||
// parse and replace values in argument string before continuing
|
||||
|
@ -124,7 +136,7 @@ func (s *service) prepareQbitOptions(action domain.Action, m domain.Macro) (map[
|
|||
return nil, errors.Wrap(err, "could not parse category macro: %v", action.Category)
|
||||
}
|
||||
|
||||
options["category"] = categoryArgs
|
||||
opts.Category = &categoryArgs
|
||||
}
|
||||
if action.Tags != "" {
|
||||
// parse and replace values in argument string before continuing
|
||||
|
@ -133,22 +145,26 @@ func (s *service) prepareQbitOptions(action domain.Action, m domain.Macro) (map[
|
|||
return nil, errors.Wrap(err, "could not parse tags macro: %v", action.Tags)
|
||||
}
|
||||
|
||||
options["tags"] = tagsArgs
|
||||
opts.Tags = &tagsArgs
|
||||
}
|
||||
if action.LimitUploadSpeed > 0 {
|
||||
options["upLimit"] = strconv.FormatInt(action.LimitUploadSpeed*1000, 10)
|
||||
opts.LimitUploadSpeed = &action.LimitUploadSpeed
|
||||
}
|
||||
if action.LimitDownloadSpeed > 0 {
|
||||
options["dlLimit"] = strconv.FormatInt(action.LimitDownloadSpeed*1000, 10)
|
||||
opts.LimitDownloadSpeed = &action.LimitDownloadSpeed
|
||||
}
|
||||
if action.LimitRatio > 0 {
|
||||
options["ratioLimit"] = strconv.FormatFloat(action.LimitRatio, 'r', 2, 64)
|
||||
opts.LimitRatio = &action.LimitRatio
|
||||
}
|
||||
if action.LimitSeedTime > 0 {
|
||||
options["seedingTimeLimit"] = strconv.FormatInt(action.LimitSeedTime, 10)
|
||||
opts.LimitSeedTime = &action.LimitSeedTime
|
||||
}
|
||||
|
||||
return options, nil
|
||||
return opts.Prepare(), nil
|
||||
}
|
||||
|
||||
func BoolPointer(b bool) *bool {
|
||||
return &b
|
||||
}
|
||||
|
||||
func (s *service) qbittorrentCheckRulesCanDownload(action domain.Action, client *domain.DownloadClient, qbt *qbittorrent.Client) ([]string, error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue