mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 08:49:13 +00:00
feat(filters): support Language filtering (#632)
* feat(filters): add support for language * feat(filters): add db migrations and repo * feat(filters): fix failing tests * feat(filters): fix failing tests
This commit is contained in:
parent
3c4711efa0
commit
5c402b6d6c
11 changed files with 120 additions and 8 deletions
|
@ -109,6 +109,8 @@ type Filter struct {
|
|||
ExceptCategories string `json:"except_categories,omitempty"`
|
||||
MatchUploaders string `json:"match_uploaders,omitempty"`
|
||||
ExceptUploaders string `json:"except_uploaders,omitempty"`
|
||||
MatchLanguage []string `json:"match_language,omitempty"`
|
||||
ExceptLanguage []string `json:"except_language,omitempty"`
|
||||
Tags string `json:"tags,omitempty"`
|
||||
ExceptTags string `json:"except_tags,omitempty"`
|
||||
TagsAny string `json:"tags_any,omitempty"`
|
||||
|
@ -182,6 +184,8 @@ type FilterUpdate struct {
|
|||
ExceptCategories *string `json:"except_categories,omitempty"`
|
||||
MatchUploaders *string `json:"match_uploaders,omitempty"`
|
||||
ExceptUploaders *string `json:"except_uploaders,omitempty"`
|
||||
MatchLanguage *[]string `json:"match_language,omitempty"`
|
||||
ExceptLanguage *[]string `json:"except_language,omitempty"`
|
||||
Tags *string `json:"tags,omitempty"`
|
||||
ExceptTags *string `json:"except_tags,omitempty"`
|
||||
TagsAny *string `json:"tags_any,omitempty"`
|
||||
|
@ -297,6 +301,14 @@ func (f Filter) CheckFilter(r *Release) ([]string, bool) {
|
|||
r.addRejectionF("unwanted uploaders. got: %v unwanted: %v", r.Uploader, f.ExceptUploaders)
|
||||
}
|
||||
|
||||
if len(f.MatchLanguage) > 0 && !sliceContainsSlice(r.Language, f.MatchLanguage) {
|
||||
r.addRejectionF("language not matching. got: %v want: %v", r.Language, f.MatchLanguage)
|
||||
}
|
||||
|
||||
if len(f.ExceptLanguage) > 0 && sliceContainsSlice(r.Language, f.ExceptLanguage) {
|
||||
r.addRejectionF("language unwanted. got: %v want: %v", r.Language, f.ExceptLanguage)
|
||||
}
|
||||
|
||||
if len(f.Resolutions) > 0 && !containsSlice(r.Resolution, f.Resolutions) {
|
||||
r.addRejectionF("resolution not matching. got: %v want: %v", r.Resolution, f.Resolutions)
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ type Release struct {
|
|||
AudioChannels string `json:"-"`
|
||||
Group string `json:"group"`
|
||||
Region string `json:"-"`
|
||||
Language string `json:"-"`
|
||||
Language []string `json:"-"`
|
||||
Proper bool `json:"proper"`
|
||||
Repack bool `json:"repack"`
|
||||
Website string `json:"website"`
|
||||
|
@ -203,6 +203,7 @@ func (r *Release) ParseString(title string) {
|
|||
r.HDR = rel.HDR
|
||||
r.Other = rel.Other
|
||||
r.Artists = rel.Artist
|
||||
r.Language = rel.Language
|
||||
|
||||
if r.Season == 0 {
|
||||
r.Season = rel.Series
|
||||
|
|
|
@ -260,6 +260,7 @@ func TestRelease_Parse(t *testing.T) {
|
|||
Year: 2022,
|
||||
Group: "GROUP1",
|
||||
Season: 1,
|
||||
Language: []string{"ENGLiSH"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -733,7 +734,7 @@ func TestRelease_DownloadTorrentFile(t *testing.T) {
|
|||
AudioChannels string
|
||||
Group string
|
||||
Region string
|
||||
Language string
|
||||
Language []string
|
||||
Proper bool
|
||||
Repack bool
|
||||
Website string
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue