mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 00:39:13 +00:00
feat(filters): RED and OPS fetch record label from API (#1881)
* feat(filters): RED and OPS fetch record label from API * test: add record label to RED and OPS test data * refactor: record label check --------- Co-authored-by: ze0s <ze0s@riseup.net>
This commit is contained in:
parent
221bc35371
commit
d153ac44b8
16 changed files with 380 additions and 154 deletions
|
@ -144,6 +144,8 @@ type Filter struct {
|
|||
ExceptCategories string `json:"except_categories,omitempty"`
|
||||
MatchUploaders string `json:"match_uploaders,omitempty"`
|
||||
ExceptUploaders string `json:"except_uploaders,omitempty"`
|
||||
MatchRecordLabels string `json:"match_record_labels,omitempty"`
|
||||
ExceptRecordLabels string `json:"except_record_labels,omitempty"`
|
||||
MatchLanguage []string `json:"match_language,omitempty"`
|
||||
ExceptLanguage []string `json:"except_language,omitempty"`
|
||||
Tags string `json:"tags,omitempty"`
|
||||
|
@ -274,6 +276,8 @@ type FilterUpdate struct {
|
|||
ExceptCategories *string `json:"except_categories,omitempty"`
|
||||
MatchUploaders *string `json:"match_uploaders,omitempty"`
|
||||
ExceptUploaders *string `json:"except_uploaders,omitempty"`
|
||||
MatchRecordLabels *string `json:"match_record_labels,omitempty"`
|
||||
ExceptRecordLabels *string `json:"except_record_labels,omitempty"`
|
||||
MatchLanguage *[]string `json:"match_language,omitempty"`
|
||||
ExceptLanguage *[]string `json:"except_language,omitempty"`
|
||||
Tags *string `json:"tags,omitempty"`
|
||||
|
@ -364,6 +368,9 @@ func (f *Filter) Sanitize() error {
|
|||
f.Artists = sanitize.FilterString(f.Artists)
|
||||
f.Albums = sanitize.FilterString(f.Albums)
|
||||
|
||||
f.MatchRecordLabels = sanitize.FilterString(f.MatchRecordLabels)
|
||||
f.ExceptRecordLabels = sanitize.FilterString(f.ExceptRecordLabels)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -465,6 +472,10 @@ func (f *Filter) CheckFilter(r *Release) (*RejectionReasons, bool) {
|
|||
// f.checkUploader sets the rejections
|
||||
}
|
||||
|
||||
if (f.MatchRecordLabels != "" || f.ExceptRecordLabels != "") && !f.checkRecordLabel(r) {
|
||||
// f.checkRecordLabel sets the rejections
|
||||
}
|
||||
|
||||
if len(f.MatchLanguage) > 0 && !sliceContainsSlice(r.Language, f.MatchLanguage) {
|
||||
f.RejectReasons.Add("match language", r.Language, f.MatchLanguage)
|
||||
}
|
||||
|
@ -749,6 +760,26 @@ func (f *Filter) checkUploader(r *Release) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
// checkRecordLabel checks if the record label is within the given list.
|
||||
// if the haystack is not empty but the record label is, then a further
|
||||
// investigation is needed
|
||||
func (f *Filter) checkRecordLabel(r *Release) bool {
|
||||
if r.RecordLabel == "" && (r.Indexer.Identifier == "redacted" || r.Indexer.Identifier == "ops") {
|
||||
r.AdditionalRecordLabelCheckRequired = true
|
||||
return true
|
||||
}
|
||||
|
||||
if f.MatchRecordLabels != "" && !contains(r.RecordLabel, f.MatchRecordLabels) {
|
||||
f.RejectReasons.Add("match record labels", r.RecordLabel, f.MatchRecordLabels)
|
||||
}
|
||||
|
||||
if f.ExceptRecordLabels != "" && contains(r.RecordLabel, f.ExceptRecordLabels) {
|
||||
f.RejectReasons.Add("except record labels", r.RecordLabel, f.ExceptRecordLabels)
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// IsPerfectFLAC Perfect is "CD FLAC Cue Log 100% Lossless or 24bit Lossless"
|
||||
func (f *Filter) IsPerfectFLAC(r *Release) ([]string, bool) {
|
||||
rejections := []string{}
|
||||
|
@ -1200,6 +1231,20 @@ func (f *Filter) CheckUploader(uploader string) (bool, error) {
|
|||
return true, nil
|
||||
}
|
||||
|
||||
func (f *Filter) CheckRecordLabel(recordLabel string) (bool, error) {
|
||||
if f.MatchRecordLabels != "" && !contains(recordLabel, f.MatchRecordLabels) {
|
||||
f.RejectReasons.Add("match record label", recordLabel, f.MatchRecordLabels)
|
||||
return false, nil
|
||||
}
|
||||
|
||||
if f.ExceptRecordLabels != "" && contains(recordLabel, f.ExceptRecordLabels) {
|
||||
f.RejectReasons.Add("except record label", recordLabel, f.ExceptRecordLabels)
|
||||
return false, nil
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// parsedSizeLimits parses filter bytes limits (expressed as a string) into a
|
||||
// uint64 number of bytes. The bounds are returned as *uint64 number of bytes,
|
||||
// with "nil" representing "no limit". We break out filter size limit parsing
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue