mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 00:39:13 +00:00
feat(releases): support magnet links (#730)
* feat(releases): support magnet links * feat(feeds): support magnet links * feat(actions): log messages * fix: component warning * fix: check hasprefix instead of hassuffix for magnet * feat(release): resolve magnet uri from link * fix(actions): deluge use magnet uri * fix(macros): add `MagnetURI` var * fix(actions): run magnet resolving before macros * feat(feeds): set download type on creation
This commit is contained in:
parent
c6101cc765
commit
ca196f0bf1
32 changed files with 770 additions and 260 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
"bytes"
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
|
@ -24,12 +25,18 @@ func (s *service) RunAction(ctx context.Context, action *domain.Action, release
|
|||
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
s.log.Error().Msgf("recovering from panic in run action %v error: %v", action.Name, r)
|
||||
err = errors.New("panic in action: %v", action.Name)
|
||||
s.log.Error().Msgf("recovering from panic in run action %s error: %v", action.Name, r)
|
||||
err = errors.New("panic in action: %s", action.Name)
|
||||
return
|
||||
}
|
||||
}()
|
||||
|
||||
// if set, try to resolve MagnetURI before parsing macros
|
||||
// to allow webhook and exec to get the magnet_uri
|
||||
if err := release.ResolveMagnetUri(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// parse all macros in one go
|
||||
if err := action.ParseMacros(release); err != nil {
|
||||
return nil, err
|
||||
|
@ -147,6 +154,10 @@ func (s *service) test(name string) {
|
|||
}
|
||||
|
||||
func (s *service) watchFolder(ctx context.Context, action *domain.Action, release domain.Release) error {
|
||||
if release.HasMagnetUri() {
|
||||
return fmt.Errorf("action watch folder does not support magnet links: %s", release.TorrentName)
|
||||
}
|
||||
|
||||
if release.TorrentTmpFile == "" {
|
||||
if err := release.DownloadTorrentFileCtx(ctx); err != nil {
|
||||
return errors.Wrap(err, "watch folder: could not download torrent file for release: %v", release.TorrentName)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue