mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 00:39:13 +00:00
fix(filters): multi-single value dynamic range matching (#2033)
This commit is contained in:
parent
7c5f5ac9fd
commit
a0dfe89032
2 changed files with 98 additions and 16 deletions
|
@ -504,11 +504,11 @@ func (f *Filter) CheckFilter(r *Release) (*RejectionReasons, bool) {
|
|||
}
|
||||
|
||||
if len(f.MatchHDR) > 0 && !matchHDR(r.HDR, f.MatchHDR) {
|
||||
f.RejectReasons.Add("match hdr", r.HDR, f.MatchHDR)
|
||||
f.RejectReasons.Add("match hdr", strings.Join(r.HDR, " "), f.MatchHDR)
|
||||
}
|
||||
|
||||
if len(f.ExceptHDR) > 0 && matchHDR(r.HDR, f.ExceptHDR) {
|
||||
f.RejectReasons.Add("except hdr", r.HDR, f.ExceptHDR)
|
||||
f.RejectReasons.Add("except hdr", strings.Join(r.HDR, " "), f.ExceptHDR)
|
||||
}
|
||||
|
||||
// Other is parsed into the Other slice from rls
|
||||
|
@ -1168,6 +1168,7 @@ func matchHDR(releaseValues []string, filterValues []string) bool {
|
|||
filter = strings.TrimSpace(filter)
|
||||
filter = strings.ToLower(filter)
|
||||
|
||||
// for filter with dual tag like "DV HDR"
|
||||
parts := strings.Split(filter, " ")
|
||||
if len(parts) == 2 {
|
||||
partsMatched := 0
|
||||
|
@ -1186,14 +1187,31 @@ func matchHDR(releaseValues []string, filterValues []string) bool {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
for _, tag := range releaseValues {
|
||||
if tag == "" {
|
||||
continue
|
||||
matches := 0
|
||||
if len(releaseValues) == 2 {
|
||||
for _, tag := range releaseValues {
|
||||
if tag == "" {
|
||||
continue
|
||||
}
|
||||
tag = strings.ToLower(tag)
|
||||
if tag == filter {
|
||||
matches++
|
||||
}
|
||||
}
|
||||
tag = strings.ToLower(tag)
|
||||
if tag == filter {
|
||||
|
||||
if matches == len(releaseValues) {
|
||||
return true
|
||||
}
|
||||
} else {
|
||||
for _, tag := range releaseValues {
|
||||
if tag == "" {
|
||||
continue
|
||||
}
|
||||
tag = strings.ToLower(tag)
|
||||
if tag == filter {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue