feat: improve release parsing and filtering (#257)

* feat(releases): improve parsing

* refactor: extend filtering add more tests

* feat: improve macro

* feat: add and remove fields

* feat: add freeleech percent to bonus

* feat: filter by origin
This commit is contained in:
Ludvig Lundgren 2022-04-30 13:43:51 +02:00 committed by GitHub
parent bb62e724a1
commit e6c151a029
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 3210 additions and 3201 deletions

View file

@ -2,6 +2,7 @@ package action
import (
"bytes"
"strings"
"text/template"
"time"
@ -14,6 +15,7 @@ type Macro struct {
TorrentHash string
TorrentUrl string
Indexer string
Title string
Resolution string
Source string
HDR string
@ -36,9 +38,10 @@ func NewMacro(release domain.Release) Macro {
TorrentPathName: release.TorrentTmpFile,
TorrentHash: release.TorrentHash,
Indexer: release.Indexer,
Title: release.Title,
Resolution: release.Resolution,
Source: release.Source,
HDR: release.HDR,
HDR: strings.Join(release.HDR, ", "),
Season: release.Season,
Episode: release.Episode,
Year: currentTime.Year(),

View file

@ -133,7 +133,7 @@ func TestMacros_Parse(t *testing.T) {
TorrentURL: "https://some.site/download/fakeid",
Indexer: "mock1",
Resolution: "2160p",
HDR: "DV",
HDR: []string{"DV"},
},
args: args{text: "movies-{{.Resolution}}{{ if .HDR }}-{{.HDR}}{{ end }}"},
want: "movies-2160p-DV",
@ -146,7 +146,7 @@ func TestMacros_Parse(t *testing.T) {
TorrentURL: "https://some.site/download/fakeid",
Indexer: "mock1",
Resolution: "2160p",
HDR: "HDR",
HDR: []string{"HDR"},
},
args: args{text: "movies-{{.Resolution}}{{ if .HDR }}-{{.HDR}}{{ end }}"},
want: "movies-2160p-HDR",