Biggest file filter
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/debridmediamanager/zurg/internal/config"
|
||||
"github.com/debridmediamanager/zurg/internal/torrent"
|
||||
"github.com/debridmediamanager/zurg/pkg/logutil"
|
||||
)
|
||||
@@ -59,6 +60,12 @@ func HandleListFiles(directory, torrentName string, torMgr *torrent.TorrentManag
|
||||
return nil, fmt.Errorf("cannot find torrent %s", torrentName)
|
||||
}
|
||||
|
||||
dirCfg := torMgr.Config.(*config.ZurgConfigV1).GetDirectoryConfig(directory)
|
||||
biggestFileSize := int64(0)
|
||||
if dirCfg.OnlyShowTheBiggestFile {
|
||||
biggestFileSize = tor.ComputeBiggestFileSize()
|
||||
}
|
||||
|
||||
htmlDoc := "<ol>"
|
||||
filenames := tor.SelectedFiles.Keys()
|
||||
sort.Strings(filenames)
|
||||
@@ -67,6 +74,9 @@ func HandleListFiles(directory, torrentName string, torMgr *torrent.TorrentManag
|
||||
if !ok || !strings.HasPrefix(file.Link, "http") {
|
||||
continue
|
||||
}
|
||||
if dirCfg.OnlyShowTheBiggestFile && file.Bytes < biggestFileSize {
|
||||
continue
|
||||
}
|
||||
filePath := filepath.Join(directory, torrentName, url.PathEscape(filename))
|
||||
htmlDoc += fmt.Sprintf("<li><a href=\"/http/%s\">%s</a></li>", filePath, filename)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user