mirror of
https://github.com/OpenListTeam/OpenList.git
synced 2025-11-24 19:12:56 +08:00
fix(strm): fix the name and type issue (#1630)
* fix(strm): fix the name and type issue * fix(strm): update version
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user