Add file size gte
This commit is contained in:
@@ -12,7 +12,7 @@ type ConfigInterface interface {
|
||||
GetHost() string
|
||||
GetPort() string
|
||||
GetDirectories() []string
|
||||
MeetsConditions(directory, torrentName string, torrentIDs, fileNames []string) bool
|
||||
MeetsConditions(directory, torrentName string, torrentSize int64, torrentIDs, fileNames []string, fileSizes []int64) bool
|
||||
GetOnLibraryUpdate() string
|
||||
GetNetworkBufferSize() int
|
||||
EnableRetainFolderNameExtension() bool
|
||||
|
||||
@@ -73,7 +73,7 @@ func (z *ZurgConfigV1) GetGroupMap() map[string][]string {
|
||||
return result
|
||||
}
|
||||
|
||||
func (z *ZurgConfigV1) MeetsConditions(directory, torrentName string, torrentIDs, fileNames []string) bool {
|
||||
func (z *ZurgConfigV1) MeetsConditions(directory, torrentName string, torrentSize int64, torrentIDs, fileNames []string, fileSizes []int64) bool {
|
||||
if directory == ALL_TORRENTS {
|
||||
return true
|
||||
}
|
||||
@@ -81,14 +81,14 @@ func (z *ZurgConfigV1) MeetsConditions(directory, torrentName string, torrentIDs
|
||||
return false
|
||||
}
|
||||
for _, filter := range z.Directories[directory].Filters {
|
||||
if z.matchFilter(torrentName, torrentIDs, fileNames, filter) {
|
||||
if z.matchFilter(torrentName, torrentSize, torrentIDs, fileNames, fileSizes, filter) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (z *ZurgConfigV1) matchFilter(torrentName string, torrentIDs, fileNames []string, filter *FilterConditionsV1) bool {
|
||||
func (z *ZurgConfigV1) matchFilter(torrentName string, torrentSize int64, torrentIDs, fileNames []string, fileSizes []int64, filter *FilterConditionsV1) bool {
|
||||
if filter.ID != "" {
|
||||
for _, torrentID := range torrentIDs {
|
||||
if torrentID == filter.ID {
|
||||
@@ -128,10 +128,16 @@ func (z *ZurgConfigV1) matchFilter(torrentName string, torrentIDs, fileNames []s
|
||||
if filter.NotContains != "" && !strings.Contains(strings.ToLower(torrentName), strings.ToLower(filter.NotContains)) {
|
||||
return true
|
||||
}
|
||||
if filter.SizeGreaterThanOrEqual > 0 && torrentSize >= filter.SizeGreaterThanOrEqual {
|
||||
return true
|
||||
}
|
||||
if filter.SizeLessThanOrEqual > 0 && torrentSize <= filter.SizeLessThanOrEqual {
|
||||
return true
|
||||
}
|
||||
if len(filter.And) > 0 {
|
||||
andResult := true
|
||||
for _, andFilter := range filter.And {
|
||||
andResult = andResult && z.matchFilter(torrentName, torrentIDs, fileNames, andFilter)
|
||||
andResult = andResult && z.matchFilter(torrentName, torrentSize, torrentIDs, fileNames, fileSizes, andFilter)
|
||||
if !andResult {
|
||||
return false
|
||||
}
|
||||
@@ -140,7 +146,7 @@ func (z *ZurgConfigV1) matchFilter(torrentName string, torrentIDs, fileNames []s
|
||||
}
|
||||
if len(filter.Or) > 0 {
|
||||
for _, orFilter := range filter.Or {
|
||||
if z.matchFilter(torrentName, torrentIDs, fileNames, orFilter) {
|
||||
if z.matchFilter(torrentName, torrentSize, torrentIDs, fileNames, fileSizes, orFilter) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -211,6 +217,20 @@ func (z *ZurgConfigV1) matchFilter(torrentName string, torrentIDs, fileNames []s
|
||||
}
|
||||
return checkArithmeticSequenceInFilenames(fileNames)
|
||||
}
|
||||
if filter.FileInsideSizeGreaterThanOrEqual > 0 {
|
||||
for _, fileSize := range fileSizes {
|
||||
if fileSize >= filter.FileInsideSizeGreaterThanOrEqual {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
if filter.FileInsideSizeLessThanOrEqual > 0 {
|
||||
for _, fileSize := range fileSizes {
|
||||
if fileSize <= filter.FileInsideSizeLessThanOrEqual {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
@@ -14,23 +14,27 @@ type DirectoryFilterConditionsV1 struct {
|
||||
}
|
||||
|
||||
type FilterConditionsV1 struct {
|
||||
ID string `yaml:"id"`
|
||||
RegexStr string `yaml:"regex"`
|
||||
Contains string `yaml:"contains"`
|
||||
ContainsStrict string `yaml:"contains_strict"`
|
||||
NotRegexStr string `yaml:"not_regex"`
|
||||
NotContains string `yaml:"not_contains"`
|
||||
NotContainsStrict string `yaml:"not_contains_strict"`
|
||||
ID string `yaml:"id"`
|
||||
RegexStr string `yaml:"regex"`
|
||||
Contains string `yaml:"contains"`
|
||||
ContainsStrict string `yaml:"contains_strict"`
|
||||
NotRegexStr string `yaml:"not_regex"`
|
||||
NotContains string `yaml:"not_contains"`
|
||||
NotContainsStrict string `yaml:"not_contains_strict"`
|
||||
SizeGreaterThanOrEqual int64 `yaml:"size_gte"`
|
||||
SizeLessThanOrEqual int64 `yaml:"size_lte"`
|
||||
|
||||
And []*FilterConditionsV1 `yaml:"and"`
|
||||
Or []*FilterConditionsV1 `yaml:"or"`
|
||||
|
||||
FileInsideRegexStr string `yaml:"any_file_inside_regex"`
|
||||
FileInsideContains string `yaml:"any_file_inside_contains"`
|
||||
FileInsideContainsStrict string `yaml:"any_file_inside_contains_strict"`
|
||||
FileInsideNotRegexStr string `yaml:"any_file_inside_not_regex"`
|
||||
FileInsideNotContains string `yaml:"any_file_inside_not_contains"`
|
||||
FileInsideNotContainsStrict string `yaml:"any_file_inside_not_contains_strict"`
|
||||
FileInsideRegexStr string `yaml:"any_file_inside_regex"`
|
||||
FileInsideContains string `yaml:"any_file_inside_contains"`
|
||||
FileInsideContainsStrict string `yaml:"any_file_inside_contains_strict"`
|
||||
FileInsideNotRegexStr string `yaml:"any_file_inside_not_regex"`
|
||||
FileInsideNotContains string `yaml:"any_file_inside_not_contains"`
|
||||
FileInsideNotContainsStrict string `yaml:"any_file_inside_not_contains_strict"`
|
||||
FileInsideSizeGreaterThanOrEqual int64 `yaml:"any_file_inside_size_gte"`
|
||||
FileInsideSizeLessThanOrEqual int64 `yaml:"any_file_inside_size_lte"`
|
||||
|
||||
HasEpisodes bool `yaml:"has_episodes"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user