mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 08:49:13 +00:00
feat: add support for proxies to use with IRC and Indexers (#1421)
* feat: add support for proxies * fix(http): release handler * fix(migrations): define proxy early * fix(migrations): pg proxy * fix(proxy): list update delete * fix(proxy): remove log and imports * feat(irc): use proxy * feat(irc): tests * fix(web): update imports for ProxyForms.tsx * fix(database): migration * feat(proxy): test * feat(proxy): validate proxy type * feat(proxy): validate and test * feat(proxy): improve validate and test * feat(proxy): fix db schema * feat(proxy): add db tests * feat(proxy): handle http errors * fix(http): imports * feat(proxy): use proxy for indexer downloads * feat(proxy): indexerforms select proxy * feat(proxy): handle torrent download * feat(proxy): skip if disabled * feat(proxy): imports * feat(proxy): implement in Feeds * feat(proxy): update helper text indexer proxy * feat(proxy): add internal cache
This commit is contained in:
parent
472d327308
commit
bc0f4cc055
59 changed files with 2533 additions and 371 deletions
|
@ -36,9 +36,8 @@ func (s *service) RunAction(ctx context.Context, action *domain.Action, release
|
|||
return nil, errors.New("action %s client %s %s not enabled, skipping", action.Name, action.Client.Type, action.Client.Name)
|
||||
}
|
||||
|
||||
// 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 {
|
||||
// Check preconditions: download torrent file if needed
|
||||
if err := s.CheckActionPreconditions(ctx, action, release); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
@ -137,6 +136,30 @@ func (s *service) RunAction(ctx context.Context, action *domain.Action, release
|
|||
return rejections, err
|
||||
}
|
||||
|
||||
func (s *service) CheckActionPreconditions(ctx context.Context, action *domain.Action, release *domain.Release) error {
|
||||
if err := s.downloadSvc.ResolveMagnetURI(ctx, release); err != nil {
|
||||
return errors.Wrap(err, "could not resolve magnet uri: %s", release.MagnetURI)
|
||||
}
|
||||
|
||||
// parse all macros in one go
|
||||
if action.CheckMacrosNeedTorrentTmpFile(release) {
|
||||
if err := s.downloadSvc.DownloadRelease(ctx, release); err != nil {
|
||||
return errors.Wrap(err, "could not download torrent file for release: %s", release.TorrentName)
|
||||
}
|
||||
}
|
||||
|
||||
if action.CheckMacrosNeedRawDataBytes(release) {
|
||||
tmpFile, err := os.ReadFile(release.TorrentTmpFile)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not read torrent file: %v", release.TorrentTmpFile)
|
||||
}
|
||||
|
||||
release.TorrentDataRawBytes = tmpFile
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *service) test(name string) {
|
||||
s.log.Info().Msgf("action TEST: %v", name)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue