feat(downloadclients): Porla support preset (#978)

* Correctly omit download/upload limits

* Prefix JWT correctly

* Allow setting Porla preset
This commit is contained in:
Viktor Elofsson 2023-06-14 19:51:34 +02:00 committed by GitHub
parent 956225c108
commit 3d9839d234
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 49 additions and 27 deletions

View file

@ -51,20 +51,32 @@ func (s *service) porla(ctx context.Context, action *domain.Action, release doma
return rejections, nil
}
var downloadLimit *int64 = nil
var uploadLimit *int64 = nil
if action.LimitDownloadSpeed > 0 {
dlValue := action.LimitDownloadSpeed * 1000
downloadLimit = &dlValue
}
if action.LimitUploadSpeed > 0 {
ulValue := action.LimitUploadSpeed * 1000
uploadLimit = &ulValue
}
var preset *string = nil
if action.Label != "" {
preset = &action.Label
}
if release.HasMagnetUri() {
opts := &porla.TorrentsAddReq{
DownloadLimit: -1,
UploadLimit: -1,
SavePath: action.SavePath,
DownloadLimit: downloadLimit,
MagnetUri: release.MagnetURI,
}
if action.LimitDownloadSpeed > 0 {
opts.DownloadLimit = action.LimitDownloadSpeed * 1000
}
if action.LimitUploadSpeed > 0 {
opts.UploadLimit = action.LimitUploadSpeed * 1000
SavePath: action.SavePath,
UploadLimit: uploadLimit,
Preset: preset,
}
if err = prl.TorrentsAdd(ctx, opts); err != nil {
@ -94,18 +106,11 @@ func (s *service) porla(ctx context.Context, action *domain.Action, release doma
}
opts := &porla.TorrentsAddReq{
DownloadLimit: -1,
DownloadLimit: downloadLimit,
SavePath: action.SavePath,
Ti: base64.StdEncoding.EncodeToString(content),
UploadLimit: -1,
}
if action.LimitDownloadSpeed > 0 {
opts.DownloadLimit = action.LimitDownloadSpeed * 1000
}
if action.LimitUploadSpeed > 0 {
opts.UploadLimit = action.LimitUploadSpeed * 1000
UploadLimit: uploadLimit,
Preset: preset,
}
if err = prl.TorrentsAdd(ctx, opts); err != nil {