mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 00:39:13 +00:00
feat(filters): RED and OPS fetch uploader from API (#1348)
* feat: added uploader when fetching torrent details on RED indexer * revert * tests * refactor(filters): size and uploader api checks * refactor(filters): fix test * refactor(filters): add mutex to rejections --------- Co-authored-by: Kyle Sanderson <kyle.leet@gmail.com> Co-authored-by: ze0s <ze0s@riseup.net>
This commit is contained in:
parent
04c4bd482f
commit
acef4ac624
8 changed files with 251 additions and 88 deletions
|
@ -460,12 +460,8 @@ func (f *Filter) CheckFilter(r *Release) (*RejectionReasons, bool) {
|
|||
}
|
||||
}
|
||||
|
||||
if f.MatchUploaders != "" && !contains(r.Uploader, f.MatchUploaders) {
|
||||
f.RejectReasons.Add("match uploaders", r.Uploader, f.MatchUploaders)
|
||||
}
|
||||
|
||||
if f.ExceptUploaders != "" && contains(r.Uploader, f.ExceptUploaders) {
|
||||
f.RejectReasons.Add("except uploaders", r.Uploader, f.ExceptUploaders)
|
||||
if (f.MatchUploaders != "" || f.ExceptUploaders != "") && !f.checkUploader(r) {
|
||||
// f.checkUploader sets the rejections
|
||||
}
|
||||
|
||||
if len(f.MatchLanguage) > 0 && !sliceContainsSlice(r.Language, f.MatchLanguage) {
|
||||
|
@ -731,6 +727,27 @@ func (f *Filter) checkSizeFilter(r *Release) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
// checkUploader checks if the uploader is within the given list.
|
||||
// if the haystack is not empty but the uploader is, then a further
|
||||
// investigation is needed
|
||||
func (f *Filter) checkUploader(r *Release) bool {
|
||||
// only support additional uploader check for RED and OPS
|
||||
if r.Uploader == "" && (r.Indexer.Identifier == "redacted" || r.Indexer.Identifier == "ops") {
|
||||
r.AdditionalUploaderCheckRequired = true
|
||||
return true
|
||||
}
|
||||
|
||||
if f.MatchUploaders != "" && !contains(r.Uploader, f.MatchUploaders) {
|
||||
f.RejectReasons.Add("match uploaders", r.Uploader, f.MatchUploaders)
|
||||
}
|
||||
|
||||
if f.ExceptUploaders != "" && contains(r.Uploader, f.ExceptUploaders) {
|
||||
f.RejectReasons.Add("except uploaders", r.Uploader, f.ExceptUploaders)
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// IsPerfectFLAC Perfect is "CD FLAC Cue Log 100% Lossless or 24bit Lossless"
|
||||
func (f *Filter) IsPerfectFLAC(r *Release) ([]string, bool) {
|
||||
rejections := []string{}
|
||||
|
@ -1168,6 +1185,20 @@ func (f *Filter) CheckReleaseSize(releaseSize uint64) (bool, error) {
|
|||
return true, nil
|
||||
}
|
||||
|
||||
func (f *Filter) CheckUploader(uploader string) (bool, error) {
|
||||
if f.MatchUploaders != "" && !contains(uploader, f.MatchUploaders) {
|
||||
f.RejectReasons.Add("match uploader", uploader, f.MatchUploaders)
|
||||
return false, nil
|
||||
}
|
||||
|
||||
if f.ExceptUploaders != "" && contains(uploader, f.ExceptUploaders) {
|
||||
f.RejectReasons.Add("except uploader", uploader, f.ExceptUploaders)
|
||||
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