mirror of
https://github.com/OpenListTeam/OpenList.git
synced 2025-11-25 03:15:19 +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", ",")
|
types := strings.Split("mp4,mkv,flv,avi,wmv,ts,rmvb,webm,mp3,flac,aac,wav,ogg,m4a,wma,alac", ",")
|
||||||
for _, ext := range types {
|
for _, ext := range types {
|
||||||
if _, ok := d.supportSuffix[ext]; !ok {
|
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", ",")
|
types = strings.Split("ass,srt,vtt,sub,strm", ",")
|
||||||
for _, ext := range types {
|
for _, ext := range types {
|
||||||
if _, ok := d.downloadSuffix[ext]; !ok {
|
if _, ok := d.downloadSuffix[ext]; !ok {
|
||||||
d.supportSuffix[ext] = struct{}{}
|
d.downloadSuffix[ext] = struct{}{}
|
||||||
downloadTypes = append(downloadTypes, ext)
|
downloadTypes = append(downloadTypes, ext)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
d.DownloadFileTypes = strings.Join(downloadTypes, ",")
|
d.DownloadFileTypes = strings.Join(downloadTypes, ",")
|
||||||
d.Version = 3
|
d.Version = 4
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package strm
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
stdpath "path"
|
stdpath "path"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -69,11 +68,12 @@ func (d *Strm) convert2strmObjs(ctx context.Context, reqPath string, objs []mode
|
|||||||
if !obj.IsDir() {
|
if !obj.IsDir() {
|
||||||
path = stdpath.Join(reqPath, obj.GetName())
|
path = stdpath.Join(reqPath, obj.GetName())
|
||||||
ext := strings.ToLower(utils.Ext(name))
|
ext := strings.ToLower(utils.Ext(name))
|
||||||
|
sourceExt := utils.SourceExt(name)
|
||||||
if _, ok := d.downloadSuffix[ext]; ok {
|
if _, ok := d.downloadSuffix[ext]; ok {
|
||||||
size = obj.GetSize()
|
size = obj.GetSize()
|
||||||
} else if _, ok := d.supportSuffix[ext]; ok {
|
} else if _, ok := d.supportSuffix[ext]; ok {
|
||||||
id = "strm"
|
id = "strm"
|
||||||
name = strings.TrimSuffix(name, ext) + "strm"
|
name = strings.TrimSuffix(name, sourceExt) + "strm"
|
||||||
size = int64(len(d.getLink(ctx, path)))
|
size = int64(len(d.getLink(ctx, path)))
|
||||||
} else {
|
} else {
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -44,11 +44,15 @@ func IsSubPath(path string, subPath string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Ext(path string) string {
|
func Ext(path string) string {
|
||||||
|
return strings.ToLower(SourceExt(path))
|
||||||
|
}
|
||||||
|
|
||||||
|
func SourceExt(path string) string {
|
||||||
ext := stdpath.Ext(path)
|
ext := stdpath.Ext(path)
|
||||||
if len(ext) > 0 && ext[0] == '.' {
|
if len(ext) > 0 && ext[0] == '.' {
|
||||||
ext = ext[1:]
|
ext = ext[1:]
|
||||||
}
|
}
|
||||||
return strings.ToLower(ext)
|
return ext
|
||||||
}
|
}
|
||||||
|
|
||||||
func EncodePath(path string, all ...bool) string {
|
func EncodePath(path string, all ...bool) string {
|
||||||
|
|||||||
Reference in New Issue
Block a user