mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 16:59:12 +00:00
parent
2daab695eb
commit
bd2769f3f2
2 changed files with 85 additions and 2 deletions
|
@ -326,12 +326,12 @@ func (f Filter) CheckFilter(r *Release) ([]string, bool) {
|
|||
}
|
||||
|
||||
// HDR is parsed into the Codec slice from rls
|
||||
if len(f.MatchHDR) > 0 && !sliceContainsSlice(r.HDR, f.MatchHDR) {
|
||||
if len(f.MatchHDR) > 0 && !matchHDR(r.HDR, f.MatchHDR) {
|
||||
r.addRejectionF("hdr not matching. got: %v want: %v", r.HDR, f.MatchHDR)
|
||||
}
|
||||
|
||||
// HDR is parsed into the Codec slice from rls
|
||||
if len(f.ExceptHDR) > 0 && sliceContainsSlice(r.HDR, f.ExceptHDR) {
|
||||
if len(f.ExceptHDR) > 0 && matchHDR(r.HDR, f.ExceptHDR) {
|
||||
r.addRejectionF("hdr unwanted. got: %v want: %v", r.HDR, f.ExceptHDR)
|
||||
}
|
||||
|
||||
|
@ -782,3 +782,45 @@ func checkFreeleechPercent(announcePercent int, filterPercent string) bool {
|
|||
|
||||
return false
|
||||
}
|
||||
|
||||
func matchHDR(releaseValues []string, filterValues []string) bool {
|
||||
|
||||
for _, filter := range filterValues {
|
||||
if filter == "" {
|
||||
continue
|
||||
}
|
||||
filter = strings.ToLower(filter)
|
||||
filter = strings.Trim(filter, " ")
|
||||
|
||||
parts := strings.Split(filter, " ")
|
||||
if len(parts) == 2 {
|
||||
partsMatched := 0
|
||||
for _, part := range parts {
|
||||
for _, tag := range releaseValues {
|
||||
if tag == "" {
|
||||
continue
|
||||
}
|
||||
tag = strings.ToLower(tag)
|
||||
if tag == part {
|
||||
partsMatched++
|
||||
}
|
||||
if len(parts) == partsMatched {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for _, tag := range releaseValues {
|
||||
if tag == "" {
|
||||
continue
|
||||
}
|
||||
tag = strings.ToLower(tag)
|
||||
if tag == filter {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -931,6 +931,47 @@ func TestFilter_CheckFilter(t *testing.T) {
|
|||
},
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "match_hdr_9",
|
||||
fields: &Release{
|
||||
TorrentName: "Good show shift S02 2160p ATVP WEB-DL DDP 5.1 Atmos DV HDR HEVC-GROUP",
|
||||
},
|
||||
args: args{
|
||||
filter: Filter{
|
||||
Enabled: true,
|
||||
MatchHDR: []string{"DV HDR"},
|
||||
},
|
||||
},
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "match_hdr_10",
|
||||
fields: &Release{
|
||||
TorrentName: "Good show shift S02 2160p ATVP WEB-DL DDP 5.1 Atmos DV HDR10 HEVC-GROUP",
|
||||
},
|
||||
args: args{
|
||||
filter: Filter{
|
||||
Enabled: true,
|
||||
MatchHDR: []string{"DV HDR"},
|
||||
},
|
||||
rejections: []string{"hdr not matching. got: [DV HDR10] want: [DV HDR]"},
|
||||
},
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "match_hdr_11",
|
||||
fields: &Release{
|
||||
TorrentName: "Good show shift S02 2160p ATVP WEB-DL DDP 5.1 Atmos HDR10 HEVC-GROUP",
|
||||
},
|
||||
args: args{
|
||||
filter: Filter{
|
||||
Enabled: true,
|
||||
MatchHDR: []string{"DV", "HDR"},
|
||||
},
|
||||
rejections: []string{"hdr not matching. got: [HDR10] want: [DV HDR]"},
|
||||
},
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "match_music_1",
|
||||
fields: &Release{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue