mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 08:49:13 +00:00
feat: add usenet support (#543)
* feat(autobrr): implement usenet support * feat(sonarr): implement usenet support * feat(radarr): implement usenet support * feat(announce): implement usenet support * announce: cast a line * feat(release): prevent unknown protocol transfer * release: lines for days. * feat: add newznab and sabnzbd support * feat: add category to sabnzbd * feat(newznab): map categories * feat(newznab): map categories --------- Co-authored-by: ze0s <43699394+zze0s@users.noreply.github.com> Co-authored-by: ze0s <ze0s@riseup.net>
This commit is contained in:
parent
b2d93d50c5
commit
13a74f7cc8
29 changed files with 1588 additions and 37 deletions
|
@ -47,8 +47,8 @@ func (s *service) radarr(ctx context.Context, action *domain.Action, release dom
|
|||
MagnetUrl: release.MagnetURI,
|
||||
Size: int64(release.Size),
|
||||
Indexer: release.Indexer,
|
||||
DownloadProtocol: "torrent",
|
||||
Protocol: "torrent",
|
||||
DownloadProtocol: string(release.Protocol),
|
||||
Protocol: string(release.Protocol),
|
||||
PublishDate: time.Now().Format(time.RFC3339),
|
||||
}
|
||||
|
||||
|
|
|
@ -85,6 +85,9 @@ func (s *service) RunAction(ctx context.Context, action *domain.Action, release
|
|||
case domain.ActionTypeReadarr:
|
||||
rejections, err = s.readarr(ctx, action, release)
|
||||
|
||||
case domain.ActionTypeSabnzbd:
|
||||
rejections, err = s.sabnzbd(ctx, action, release)
|
||||
|
||||
default:
|
||||
s.log.Warn().Msgf("unsupported action type: %v", action.Type)
|
||||
return rejections, err
|
||||
|
|
52
internal/action/sabnzbd.go
Normal file
52
internal/action/sabnzbd.go
Normal file
|
@ -0,0 +1,52 @@
|
|||
package action
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/autobrr/autobrr/internal/domain"
|
||||
"github.com/autobrr/autobrr/pkg/errors"
|
||||
"github.com/autobrr/autobrr/pkg/sabnzbd"
|
||||
)
|
||||
|
||||
func (s *service) sabnzbd(ctx context.Context, action *domain.Action, release domain.Release) ([]string, error) {
|
||||
s.log.Trace().Msg("action Sabnzbd")
|
||||
|
||||
if release.Protocol != domain.ReleaseProtocolNzb {
|
||||
return nil, errors.New("action type: %s invalid protocol: %s", action.Type, release.Protocol)
|
||||
}
|
||||
|
||||
// get client for action
|
||||
client, err := s.clientSvc.FindByID(ctx, action.ClientID)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "sonarr could not find client: %d", action.ClientID)
|
||||
}
|
||||
|
||||
// return early if no client found
|
||||
if client == nil {
|
||||
return nil, errors.New("no sabnzbd client found by id: %d", action.ClientID)
|
||||
}
|
||||
|
||||
opts := sabnzbd.Options{
|
||||
Addr: client.Host,
|
||||
ApiKey: client.Settings.APIKey,
|
||||
Log: nil,
|
||||
}
|
||||
|
||||
if client.Settings.Basic.Auth {
|
||||
opts.BasicUser = client.Settings.Basic.Username
|
||||
opts.BasicPass = client.Settings.Basic.Password
|
||||
}
|
||||
|
||||
sab := sabnzbd.New(opts)
|
||||
|
||||
ids, err := sab.AddFromUrl(ctx, sabnzbd.AddNzbRequest{Url: release.TorrentURL, Category: action.Category})
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not add nzb to sabnzbd")
|
||||
}
|
||||
|
||||
s.log.Trace().Msgf("nzb successfully added to client: '%+v'", ids)
|
||||
|
||||
s.log.Info().Msgf("nzb successfully added to client: '%s'", client.Name)
|
||||
|
||||
return nil, nil
|
||||
}
|
|
@ -47,8 +47,8 @@ func (s *service) sonarr(ctx context.Context, action *domain.Action, release dom
|
|||
MagnetUrl: release.MagnetURI,
|
||||
Size: int64(release.Size),
|
||||
Indexer: release.Indexer,
|
||||
DownloadProtocol: "torrent",
|
||||
Protocol: "torrent",
|
||||
DownloadProtocol: string(release.Protocol),
|
||||
Protocol: string(release.Protocol),
|
||||
PublishDate: time.Now().Format(time.RFC3339),
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue