feat(filters): regex match release support list (#265)

This commit is contained in:
Ludvig Lundgren 2022-05-03 15:26:13 +02:00 committed by GitHub
parent 8b1174c65f
commit 9d52d42440
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 5 deletions

View file

@ -319,13 +319,21 @@ func (f Filter) checkSizeFilter(r *Release, minSize string, maxSize string) bool
return true
}
func matchRegex(tag string, filter string) bool {
re, err := regexp.Compile(`(?i)(?:` + filter + `)`)
if err != nil {
return false
func matchRegex(tag string, filterList string) bool {
filters := strings.Split(filterList, ",")
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"

View file

@ -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_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 {
t.Run(tt.name, func(t *testing.T) {