mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 08:49:13 +00:00
feat(filters): filtering for raw releaseTags (#506)
feat(filters): add releaseTags filtering
This commit is contained in:
parent
dbabb26b83
commit
5183f7683a
7 changed files with 166 additions and 18 deletions
|
@ -112,6 +112,9 @@ type Filter struct {
|
|||
ExceptTags string `json:"except_tags,omitempty"`
|
||||
TagsAny string `json:"tags_any,omitempty"`
|
||||
ExceptTagsAny string `json:"except_tags_any,omitempty"`
|
||||
MatchReleaseTags string `json:"match_release_tags,omitempty"`
|
||||
ExceptReleaseTags string `json:"except_release_tags,omitempty"`
|
||||
UseRegexReleaseTags bool `json:"use_regex_release_tags,omitempty"`
|
||||
ExternalScriptEnabled bool `json:"external_script_enabled,omitempty"`
|
||||
ExternalScriptCmd string `json:"external_script_cmd,omitempty"`
|
||||
ExternalScriptArgs string `json:"external_script_args,omitempty"`
|
||||
|
@ -141,6 +144,9 @@ type FilterUpdate struct {
|
|||
UseRegex *bool `json:"use_regex,omitempty"`
|
||||
MatchReleaseGroups *string `json:"match_release_groups,omitempty"`
|
||||
ExceptReleaseGroups *string `json:"except_release_groups,omitempty"`
|
||||
MatchReleaseTags *string `json:"match_release_tags,omitempty"`
|
||||
ExceptReleaseTags *string `json:"except_release_tags,omitempty"`
|
||||
UseRegexReleaseTags *bool `json:"use_regex_release_tags,omitempty"`
|
||||
Scene *bool `json:"scene,omitempty"`
|
||||
Origins *[]string `json:"origins,omitempty"`
|
||||
ExceptOrigins *[]string `json:"except_origins,omitempty"`
|
||||
|
@ -261,6 +267,26 @@ func (f Filter) CheckFilter(r *Release) ([]string, bool) {
|
|||
r.addRejectionF("unwanted release group. got: %v unwanted: %v", r.Group, f.ExceptReleaseGroups)
|
||||
}
|
||||
|
||||
// check raw releaseTags string
|
||||
if f.UseRegexReleaseTags {
|
||||
if f.MatchReleaseTags != "" && !matchRegex(r.ReleaseTags, f.MatchReleaseTags) {
|
||||
r.addRejectionF("match release tags regex not matching. got: %v want: %v", r.ReleaseTags, f.MatchReleaseTags)
|
||||
}
|
||||
|
||||
if f.ExceptReleaseTags != "" && matchRegex(r.ReleaseTags, f.ExceptReleaseTags) {
|
||||
r.addRejectionF("except release tags regex: unwanted release. got: %v want: %v", r.ReleaseTags, f.ExceptReleaseTags)
|
||||
}
|
||||
|
||||
} else {
|
||||
if f.MatchReleaseTags != "" && !containsFuzzy(r.ReleaseTags, f.MatchReleaseTags) {
|
||||
r.addRejectionF("match release tags not matching. got: %v want: %v", r.ReleaseTags, f.MatchReleaseTags)
|
||||
}
|
||||
|
||||
if f.ExceptReleaseTags != "" && containsFuzzy(r.ReleaseTags, f.ExceptReleaseTags) {
|
||||
r.addRejectionF("except release tags: unwanted release. got: %v want: %v", r.ReleaseTags, f.ExceptReleaseTags)
|
||||
}
|
||||
}
|
||||
|
||||
if f.MatchUploaders != "" && !contains(r.Uploader, f.MatchUploaders) {
|
||||
r.addRejectionF("uploaders not matching. got: %v want: %v", r.Uploader, f.MatchUploaders)
|
||||
}
|
||||
|
|
|
@ -1581,6 +1581,45 @@ func TestFilter_CheckFilter1(t *testing.T) {
|
|||
wantRejections: nil,
|
||||
wantMatch: true,
|
||||
},
|
||||
{
|
||||
name: "test_39",
|
||||
fields: fields{
|
||||
UseRegexReleaseTags: true,
|
||||
MatchReleaseTags: ".*1080p.+(group1|group3)",
|
||||
},
|
||||
args: args{&Release{TorrentName: "Show.Name.S01.DV.2160p.ATVP.WEB-DL.DDPA5.1.x265-GROUP2", ReleaseTags: "MKV | x264 | WEB | P2P"}},
|
||||
wantRejections: []string{"match release tags regex not matching. got: MKV | x264 | WEB | P2P want: .*1080p.+(group1|group3)"},
|
||||
wantMatch: false,
|
||||
},
|
||||
{
|
||||
name: "test_40",
|
||||
fields: fields{
|
||||
UseRegexReleaseTags: true,
|
||||
MatchReleaseTags: "foreign - 16",
|
||||
},
|
||||
args: args{&Release{TorrentName: "Show.Name.S01.DV.2160p.ATVP.WEB-DL.DDPA5.1.x265-GROUP2", ReleaseTags: "MKV | x264 | WEB | P2P | Foreign - 17"}},
|
||||
wantRejections: []string{"match release tags regex not matching. got: MKV | x264 | WEB | P2P | Foreign - 17 want: foreign - 16"},
|
||||
wantMatch: false,
|
||||
},
|
||||
{
|
||||
name: "test_41",
|
||||
fields: fields{
|
||||
UseRegexReleaseTags: true,
|
||||
MatchReleaseTags: "foreign - 17",
|
||||
},
|
||||
args: args{&Release{TorrentName: "Show.Name.S01.DV.2160p.ATVP.WEB-DL.DDPA5.1.x265-GROUP2", ReleaseTags: "MKV | x264 | WEB | P2P | Foreign - 17"}},
|
||||
wantMatch: true,
|
||||
},
|
||||
{
|
||||
name: "test_42",
|
||||
fields: fields{
|
||||
UseRegexReleaseTags: true,
|
||||
MatchReleaseTags: "foreign - 17",
|
||||
},
|
||||
args: args{&Release{TorrentName: "Show.Name.S01.DV.2160p.ATVP.WEB-DL.DDPA5.1.x265-GROUP2", ReleaseTags: ""}},
|
||||
wantRejections: []string{"match release tags regex not matching. got: want: foreign - 17"},
|
||||
wantMatch: false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
@ -1601,6 +1640,9 @@ func TestFilter_CheckFilter1(t *testing.T) {
|
|||
UseRegex: tt.fields.UseRegex,
|
||||
MatchReleaseGroups: tt.fields.MatchReleaseGroups,
|
||||
ExceptReleaseGroups: tt.fields.ExceptReleaseGroups,
|
||||
MatchReleaseTags: tt.fields.MatchReleaseTags,
|
||||
ExceptReleaseTags: tt.fields.ExceptReleaseTags,
|
||||
UseRegexReleaseTags: tt.fields.UseRegexReleaseTags,
|
||||
Scene: tt.fields.Scene,
|
||||
Origins: tt.fields.Origins,
|
||||
ExceptOrigins: tt.fields.ExceptOrigins,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue