feat(actions): add more macro variables (#157)

* feat(actions): add more macro variables

* feat: add more macros

* feat: add more tests
This commit is contained in:
Ludvig Lundgren 2022-03-04 20:29:53 +01:00 committed by GitHub
parent e0e4bf6202
commit 5a45851677
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 252 additions and 68 deletions

View file

@ -3,12 +3,53 @@ package action
import (
"bytes"
"text/template"
"time"
"github.com/autobrr/autobrr/internal/domain"
)
type Macro struct {
TorrentName string
TorrentPathName string
TorrentHash string
TorrentUrl string
Indexer string
Resolution string
Source string
HDR string
Season int
Episode int
Year int
Month int
Day int
Hour int
Minute int
Second int
}
func NewMacro(release domain.Release) Macro {
currentTime := time.Now()
ma := Macro{
TorrentName: release.TorrentName,
TorrentUrl: release.TorrentURL,
TorrentPathName: release.TorrentTmpFile,
TorrentHash: release.TorrentHash,
Indexer: release.Indexer,
Resolution: release.Resolution,
Source: release.Source,
HDR: release.HDR,
Season: release.Season,
Episode: release.Episode,
Year: currentTime.Year(),
Month: int(currentTime.Month()),
Day: currentTime.Day(),
Hour: currentTime.Hour(),
Minute: currentTime.Minute(),
Second: currentTime.Second(),
}
return ma
}
// Parse takes a string and replaces valid vars