diff --git a/drivers/strm/driver.go b/drivers/strm/driver.go index c1b1f042..04716542 100644 --- a/drivers/strm/driver.go +++ b/drivers/strm/driver.go @@ -96,7 +96,7 @@ func (d *Strm) Init(ctx context.Context) error { } } - if d.Version != 3 { + if d.Version != 4 { types := strings.Split("mp4,mkv,flv,avi,wmv,ts,rmvb,webm,mp3,flac,aac,wav,ogg,m4a,wma,alac", ",") for _, ext := range types { if _, ok := d.supportSuffix[ext]; !ok { @@ -109,12 +109,12 @@ func (d *Strm) Init(ctx context.Context) error { types = strings.Split("ass,srt,vtt,sub,strm", ",") for _, ext := range types { if _, ok := d.downloadSuffix[ext]; !ok { - d.supportSuffix[ext] = struct{}{} + d.downloadSuffix[ext] = struct{}{} downloadTypes = append(downloadTypes, ext) } } d.DownloadFileTypes = strings.Join(downloadTypes, ",") - d.Version = 3 + d.Version = 4 } return nil } diff --git a/drivers/strm/util.go b/drivers/strm/util.go index 54e47a68..a8c090fd 100644 --- a/drivers/strm/util.go +++ b/drivers/strm/util.go @@ -3,7 +3,6 @@ package strm import ( "context" "fmt" - stdpath "path" "strings" @@ -69,11 +68,12 @@ func (d *Strm) convert2strmObjs(ctx context.Context, reqPath string, objs []mode if !obj.IsDir() { path = stdpath.Join(reqPath, obj.GetName()) ext := strings.ToLower(utils.Ext(name)) + sourceExt := utils.SourceExt(name) if _, ok := d.downloadSuffix[ext]; ok { size = obj.GetSize() } else if _, ok := d.supportSuffix[ext]; ok { id = "strm" - name = strings.TrimSuffix(name, ext) + "strm" + name = strings.TrimSuffix(name, sourceExt) + "strm" size = int64(len(d.getLink(ctx, path))) } else { continue diff --git a/pkg/utils/path.go b/pkg/utils/path.go index 2a104ff5..ec75501e 100644 --- a/pkg/utils/path.go +++ b/pkg/utils/path.go @@ -44,11 +44,15 @@ func IsSubPath(path string, subPath string) bool { } func Ext(path string) string { + return strings.ToLower(SourceExt(path)) +} + +func SourceExt(path string) string { ext := stdpath.Ext(path) if len(ext) > 0 && ext[0] == '.' { ext = ext[1:] } - return strings.ToLower(ext) + return ext } func EncodePath(path string, all ...bool) string {