diff --git a/internal/config/v1types.go b/internal/config/v1types.go index 22c8b7c..0591d48 100644 --- a/internal/config/v1types.go +++ b/internal/config/v1types.go @@ -8,10 +8,12 @@ type ZurgConfigV1 struct { log *logutil.Logger } type Directory struct { - GroupOrder int `yaml:"group_order"` - Group string `yaml:"group"` - Filters []*FilterConditionsV1 `yaml:"filters"` - OnlyShowTheBiggestFile bool `yaml:"only_show_the_biggest_file"` + GroupOrder int `yaml:"group_order"` + Group string `yaml:"group"` + Filters []*FilterConditionsV1 `yaml:"filters"` + OnlyShowTheBiggestFile bool `yaml:"only_show_the_biggest_file"` + OnlyShowFilesWithSizeLte int64 `yaml:"only_show_files_with_size_lte"` + OnlyShowFilesWithSizeGte int64 `yaml:"only_show_files_with_size_gte"` } type FilterConditionsV1 struct { diff --git a/internal/dav/infuse.go b/internal/dav/infuse.go index ff03c29..c02261e 100644 --- a/internal/dav/infuse.go +++ b/internal/dav/infuse.go @@ -76,6 +76,12 @@ func ServeFilesListForInfuse(directory, torrentName string, torMgr *torrent.Torr if dirCfg.OnlyShowTheBiggestFile && file.Bytes < biggestFileSize { continue } + if dirCfg.OnlyShowFilesWithSizeLte > 0 && file.Bytes > dirCfg.OnlyShowFilesWithSizeLte { + continue + } + if dirCfg.OnlyShowFilesWithSizeGte > 0 && file.Bytes < dirCfg.OnlyShowFilesWithSizeGte { + continue + } buf.WriteString(dav.File(filename, file.Bytes, file.Ended)) } buf.WriteString("") diff --git a/internal/dav/listing.go b/internal/dav/listing.go index b8cea39..bbb9f91 100644 --- a/internal/dav/listing.go +++ b/internal/dav/listing.go @@ -80,6 +80,12 @@ func ServeFilesList(directory, torrentName string, torMgr *torrent.TorrentManage if dirCfg.OnlyShowTheBiggestFile && file.Bytes < biggestFileSize { continue } + if dirCfg.OnlyShowFilesWithSizeLte > 0 && file.Bytes > dirCfg.OnlyShowFilesWithSizeLte { + continue + } + if dirCfg.OnlyShowFilesWithSizeGte > 0 && file.Bytes < dirCfg.OnlyShowFilesWithSizeGte { + continue + } buf.WriteString(dav.File(filename, file.Bytes, file.Ended)) } buf.WriteString("") diff --git a/internal/http/listing.go b/internal/http/listing.go index f1a984c..cb9c4b4 100644 --- a/internal/http/listing.go +++ b/internal/http/listing.go @@ -77,6 +77,12 @@ func ServeFilesList(directory, torrentName string, torMgr *torrent.TorrentManage if dirCfg.OnlyShowTheBiggestFile && file.Bytes < biggestFileSize { continue } + if dirCfg.OnlyShowFilesWithSizeLte > 0 && file.Bytes > dirCfg.OnlyShowFilesWithSizeLte { + continue + } + if dirCfg.OnlyShowFilesWithSizeGte > 0 && file.Bytes < dirCfg.OnlyShowFilesWithSizeGte { + continue + } filePath := filepath.Join(directory, torrentName, url.PathEscape(filename)) buf.WriteString(fmt.Sprintf("
  • %s
  • ", filePath, filename)) } diff --git a/internal/torrent/manager.go b/internal/torrent/manager.go index 8ea4a04..8ec2995 100644 --- a/internal/torrent/manager.go +++ b/internal/torrent/manager.go @@ -141,7 +141,8 @@ func (t *TorrentManager) assignedDirectoryCb(tor *Torrent, cb func(string)) { if unplayable { cb(config.UNPLAYABLE_TORRENTS) break - } else if t.Config.MeetsConditions(directory, tor.AccessKey, tor.ComputeTotalSize(), torrentIDs, filenames, fileSizes) { + } + if t.Config.MeetsConditions(directory, tor.AccessKey, tor.ComputeTotalSize(), torrentIDs, filenames, fileSizes) { cb(directory) break }