mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 16:59:12 +00:00
fix(filters): except categories (#510)
fix(filters): except categories check
This commit is contained in:
parent
2cc08bed71
commit
532df38cd4
2 changed files with 55 additions and 3 deletions
|
@ -341,7 +341,7 @@ func (f Filter) CheckFilter(r *Release) ([]string, bool) {
|
|||
if r.Category != "" {
|
||||
categories = append(categories, r.Category)
|
||||
}
|
||||
if !contains(r.Category, f.MatchCategories) && !containsAny(r.Categories, f.MatchCategories) {
|
||||
if !contains(r.Category, f.MatchCategories) && !containsAny(categories, f.MatchCategories) {
|
||||
r.addRejectionF("category not matching. got: %v want: %v", strings.Join(categories, ","), f.MatchCategories)
|
||||
}
|
||||
}
|
||||
|
@ -352,8 +352,8 @@ func (f Filter) CheckFilter(r *Release) ([]string, bool) {
|
|||
if r.Category != "" {
|
||||
categories = append(categories, r.Category)
|
||||
}
|
||||
if !contains(r.Category, f.ExceptCategories) && !containsAny(r.Categories, f.ExceptCategories) {
|
||||
r.addRejectionF("category unwanted. got: %v want: %v", strings.Join(categories, ","), f.ExceptCategories)
|
||||
if contains(r.Category, f.ExceptCategories) && containsAny(categories, f.ExceptCategories) {
|
||||
r.addRejectionF("category unwanted. got: %v unwanted: %v", strings.Join(categories, ","), f.ExceptCategories)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -226,6 +226,58 @@ func TestFilter_CheckFilter(t *testing.T) {
|
|||
},
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "movie_except_category_1",
|
||||
fields: &Release{
|
||||
TorrentName: "That Movie 2020 2160p BluRay DD5.1 x264-GROUP1",
|
||||
Category: "Movies",
|
||||
Freeleech: true,
|
||||
Size: uint64(30000000001), // 30GB
|
||||
},
|
||||
args: args{
|
||||
filter: Filter{
|
||||
Enabled: true,
|
||||
ExceptCategories: "*movies*",
|
||||
Freeleech: true,
|
||||
MinSize: "10 GB",
|
||||
MaxSize: "40GB",
|
||||
Resolutions: []string{"1080p", "2160p"},
|
||||
Sources: []string{"BluRay"},
|
||||
Codecs: []string{"x264"},
|
||||
Years: "2015,2018-2022",
|
||||
MatchReleaseGroups: "GROUP1,BADGROUP",
|
||||
Shows: "*Movie*, good story, bad movie",
|
||||
},
|
||||
rejections: []string{"category unwanted. got: Movies unwanted: *movies*"},
|
||||
},
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "movie_except_category_1",
|
||||
fields: &Release{
|
||||
TorrentName: "That Movie 2020 2160p BluRay DD5.1 x264-GROUP1",
|
||||
Category: "Movies",
|
||||
Freeleech: true,
|
||||
Size: uint64(30000000001), // 30GB
|
||||
},
|
||||
args: args{
|
||||
filter: Filter{
|
||||
Enabled: true,
|
||||
ExceptCategories: "*tv*",
|
||||
Freeleech: true,
|
||||
MinSize: "10 GB",
|
||||
MaxSize: "40GB",
|
||||
Resolutions: []string{"1080p", "2160p"},
|
||||
Sources: []string{"BluRay"},
|
||||
Codecs: []string{"x264"},
|
||||
Years: "2015,2018-2022",
|
||||
MatchReleaseGroups: "GROUP1,BADGROUP",
|
||||
Shows: "*Movie*, good story, bad movie",
|
||||
},
|
||||
rejections: nil,
|
||||
},
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "movie_bad_category",
|
||||
fields: &Release{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue