mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 08:49:13 +00:00
feat(filters): add support for feed description (#922)
* feat(filters): match description * feat(filters): support description * chore: remove match logic for description * fix: update rss tests
This commit is contained in:
parent
058627f4e5
commit
e5b4ded725
9 changed files with 105 additions and 7 deletions
|
@ -124,6 +124,9 @@ type Filter struct {
|
|||
MatchReleaseTags string `json:"match_release_tags,omitempty"`
|
||||
ExceptReleaseTags string `json:"except_release_tags,omitempty"`
|
||||
UseRegexReleaseTags bool `json:"use_regex_release_tags,omitempty"`
|
||||
MatchDescription string `json:"match_description,omitempty"`
|
||||
ExceptDescription string `json:"except_description,omitempty"`
|
||||
UseRegexDescription bool `json:"use_regex_description,omitempty"`
|
||||
ExternalScriptEnabled bool `json:"external_script_enabled,omitempty"`
|
||||
ExternalScriptCmd string `json:"external_script_cmd,omitempty"`
|
||||
ExternalScriptArgs string `json:"external_script_args,omitempty"`
|
||||
|
@ -156,6 +159,9 @@ type FilterUpdate struct {
|
|||
MatchReleaseTags *string `json:"match_release_tags,omitempty"`
|
||||
ExceptReleaseTags *string `json:"except_release_tags,omitempty"`
|
||||
UseRegexReleaseTags *bool `json:"use_regex_release_tags,omitempty"`
|
||||
MatchDescription *string `json:"match_description,omitempty"`
|
||||
ExceptDescription *string `json:"except_description,omitempty"`
|
||||
UseRegexDescription *bool `json:"use_regex_description,omitempty"`
|
||||
Scene *bool `json:"scene,omitempty"`
|
||||
Origins *[]string `json:"origins,omitempty"`
|
||||
ExceptOrigins *[]string `json:"except_origins,omitempty"`
|
||||
|
@ -440,6 +446,26 @@ func (f Filter) CheckFilter(r *Release) ([]string, bool) {
|
|||
r.addRejectionF("log score. got: %v want: %v", r.LogScore, f.LogScore)
|
||||
}
|
||||
|
||||
// check description string
|
||||
if f.UseRegexDescription {
|
||||
if f.MatchDescription != "" && !matchRegex(r.Description, f.MatchDescription) {
|
||||
r.addRejectionF("match description regex not matching. got: %v want: %v", r.Description, f.MatchDescription)
|
||||
}
|
||||
|
||||
if f.ExceptDescription != "" && matchRegex(r.Description, f.ExceptDescription) {
|
||||
r.addRejectionF("except description regex: unwanted release. got: %v want: %v", r.Description, f.ExceptDescription)
|
||||
}
|
||||
|
||||
} else {
|
||||
if f.MatchDescription != "" && !containsFuzzy(r.Description, f.MatchDescription) {
|
||||
r.addRejectionF("match description not matching. got: %v want: %v", r.Description, f.MatchDescription)
|
||||
}
|
||||
|
||||
if f.ExceptDescription != "" && containsFuzzy(r.Description, f.ExceptDescription) {
|
||||
r.addRejectionF("except description: unwanted release. got: %v want: %v", r.Description, f.ExceptDescription)
|
||||
}
|
||||
}
|
||||
|
||||
if len(r.Rejections) > 0 {
|
||||
return r.Rejections, false
|
||||
}
|
||||
|
|
|
@ -58,6 +58,7 @@ type Release struct {
|
|||
TorrentName string `json:"torrent_name"` // full release name
|
||||
Size uint64 `json:"size"`
|
||||
Title string `json:"title"` // Parsed title
|
||||
Description string `json:"-"`
|
||||
Category string `json:"category"`
|
||||
Categories []string `json:"categories,omitempty"`
|
||||
Season int `json:"season"`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue