diff --git a/drivers/strm/driver.go b/drivers/strm/driver.go index 1189fd9a7..3d243c157 100644 --- a/drivers/strm/driver.go +++ b/drivers/strm/driver.go @@ -27,6 +27,7 @@ type Strm struct { supportSuffix map[string]struct{} downloadSuffix map[string]struct{} + minSizeBytes int64 } func (d *Strm) Config() driver.Config { @@ -120,6 +121,7 @@ func (d *Strm) Init(ctx context.Context) error { if len(d.SaveLocalMode) == 0 { d.SaveLocalMode = SaveLocalInsertMode } + d.minSizeBytes = d.MinFileSize * 1024 * 1024 return nil } diff --git a/drivers/strm/meta.go b/drivers/strm/meta.go index 843ff7c66..2e2e8a08e 100644 --- a/drivers/strm/meta.go +++ b/drivers/strm/meta.go @@ -17,6 +17,7 @@ type Addition struct { PathPrefix string `json:"PathPrefix" type:"text" required:"false" default:"/d" help:"Path prefix"` DownloadFileTypes string `json:"downloadFileTypes" type:"text" default:"ass,srt,vtt,sub,strm" required:"false" help:"Files need to download with strm (usally subtitles)"` FilterFileTypes string `json:"filterFileTypes" type:"text" default:"mp4,mkv,flv,avi,wmv,ts,rmvb,webm,mp3,flac,aac,wav,ogg,m4a,wma,alac" required:"false" help:"Supports suffix name of strm file"` + MinFileSize int64 `json:"minFileSize" type:"number" required:"false" default:"0" help:"Filter out files smaller than this size (unit: MB, 0 to disable)"` EncodePath bool `json:"encodePath" default:"true" required:"true" help:"encode the path in the strm file"` WithoutUrl bool `json:"withoutUrl" default:"false" help:"strm file content without URL prefix"` WithSign bool `json:"withSign" default:"false"` diff --git a/drivers/strm/util.go b/drivers/strm/util.go index b9a40da5e..7dfc7dbee 100644 --- a/drivers/strm/util.go +++ b/drivers/strm/util.go @@ -73,6 +73,9 @@ func (d *Strm) convert2strmObjs(ctx context.Context, reqPath string, objs []mode if _, ok := d.downloadSuffix[ext]; ok { size = obj.GetSize() } else if _, ok := d.supportSuffix[ext]; ok { + if d.minSizeBytes > 0 && obj.GetSize() < d.minSizeBytes { + continue + } id = "strm" name = strings.TrimSuffix(name, sourceExt) + "strm" size = int64(len(d.getLink(ctx, path)))