mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 00:39:13 +00:00
feat(filters): regex match release support list (#265)
This commit is contained in:
parent
8b1174c65f
commit
9d52d42440
2 changed files with 15 additions and 5 deletions
|
@ -319,13 +319,21 @@ func (f Filter) checkSizeFilter(r *Release, minSize string, maxSize string) bool
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func matchRegex(tag string, filter string) bool {
|
func matchRegex(tag string, filterList string) bool {
|
||||||
re, err := regexp.Compile(`(?i)(?:` + filter + `)`)
|
filters := strings.Split(filterList, ",")
|
||||||
if err != nil {
|
|
||||||
return false
|
for _, filter := range filters {
|
||||||
|
re, err := regexp.Compile(`(?i)(?:` + filter + `)`)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
match := re.MatchString(tag)
|
||||||
|
if match {
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return re.MatchString(tag)
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// checkFilterIntStrings "1,2,3-20"
|
// checkFilterIntStrings "1,2,3-20"
|
||||||
|
|
|
@ -1598,6 +1598,8 @@ func Test_matchRegex(t *testing.T) {
|
||||||
}{
|
}{
|
||||||
{name: "test_1", args: args{tag: "Some.show.S01.DV.2160p.ATVP.WEB-DL.DDPA5.1.x265-GROUP1", filter: ".*2160p.+(group1|group2)"}, want: true},
|
{name: "test_1", args: args{tag: "Some.show.S01.DV.2160p.ATVP.WEB-DL.DDPA5.1.x265-GROUP1", filter: ".*2160p.+(group1|group2)"}, want: true},
|
||||||
{name: "test_2", args: args{tag: "Some.show.S01.DV.2160p.ATVP.WEB-DL.DDPA5.1.x265-GROUP2", filter: ".*1080p.+(group1|group3)"}, want: false},
|
{name: "test_2", args: args{tag: "Some.show.S01.DV.2160p.ATVP.WEB-DL.DDPA5.1.x265-GROUP2", filter: ".*1080p.+(group1|group3)"}, want: false},
|
||||||
|
{name: "test_3", args: args{tag: "Some.show.S01.DV.2160p.ATVP.WEB-DL.DDPA5.1.x265-GROUP2", filter: ".*1080p.+(group1|group3),.*2160p.+"}, want: true},
|
||||||
|
{name: "test_4", args: args{tag: "Some.show.S01.DV.2160p.ATVP.WEB-DL.DDPA5.1.x265-GROUP2", filter: ".*1080p.+(group1|group3),.*720p.+"}, want: false},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue