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
|
@ -14,11 +14,11 @@ import (
|
|||
)
|
||||
|
||||
func (s *service) execCmd(ctx context.Context, action *domain.Action, release domain.Release) error {
|
||||
s.log.Debug().Msgf("action exec: %v release: %v", action.Name, release.TorrentName)
|
||||
s.log.Debug().Msgf("action exec: %s release: %s", action.Name, release.TorrentName)
|
||||
|
||||
if release.TorrentTmpFile == "" && strings.Contains(action.ExecArgs, "TorrentPathName") {
|
||||
if err := release.DownloadTorrentFileCtx(ctx); err != nil {
|
||||
return errors.Wrap(err, "error downloading torrent file for release: %v", release.TorrentName)
|
||||
return errors.Wrap(err, "error downloading torrent file for release: %s", release.TorrentName)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ func (s *service) execCmd(ctx context.Context, action *domain.Action, release do
|
|||
if len(release.TorrentDataRawBytes) == 0 && release.TorrentTmpFile != "" {
|
||||
t, err := os.ReadFile(release.TorrentTmpFile)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not read torrent file: %v", release.TorrentTmpFile)
|
||||
return errors.Wrap(err, "could not read torrent file: %s", release.TorrentTmpFile)
|
||||
}
|
||||
|
||||
release.TorrentDataRawBytes = t
|
||||
|
@ -35,14 +35,14 @@ func (s *service) execCmd(ctx context.Context, action *domain.Action, release do
|
|||
// check if program exists
|
||||
cmd, err := exec.LookPath(action.ExecCmd)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "exec failed, could not find program: %v", action.ExecCmd)
|
||||
return errors.Wrap(err, "exec failed, could not find program: %s", action.ExecCmd)
|
||||
}
|
||||
|
||||
p := shellwords.NewParser()
|
||||
p.ParseBacktick = true
|
||||
args, err := p.Parse(action.ExecArgs)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not parse exec args: %v", action.ExecArgs)
|
||||
return errors.Wrap(err, "could not parse exec args: %s", action.ExecArgs)
|
||||
}
|
||||
|
||||
// we need to split on space into a string slice, so we can spread the args into exec
|
||||
|
@ -56,14 +56,14 @@ func (s *service) execCmd(ctx context.Context, action *domain.Action, release do
|
|||
output, err := command.CombinedOutput()
|
||||
if err != nil {
|
||||
// everything other than exit 0 is considered an error
|
||||
return errors.Wrap(err, "error executing command: %v args: %v", cmd, args)
|
||||
return errors.Wrap(err, "error executing command: %s args: %s", cmd, args)
|
||||
}
|
||||
|
||||
s.log.Trace().Msgf("executed command: '%v'", string(output))
|
||||
s.log.Trace().Msgf("executed command: '%s'", string(output))
|
||||
|
||||
duration := time.Since(start)
|
||||
|
||||
s.log.Info().Msgf("executed command: '%v', args: '%v' %v,%v, total time %v", cmd, args, release.TorrentName, release.Indexer, duration)
|
||||
s.log.Info().Msgf("executed command: '%s', args: '%s' %s,%s, total time %v", cmd, args, release.TorrentName, release.Indexer, duration)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue