mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 08:49:13 +00:00
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:
parent
e0e4bf6202
commit
5a45851677
6 changed files with 252 additions and 68 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue