Skip to content

Commit 4c0916b

Browse files
authored
fix(strm): fix the name and type issue (#1630)
* fix(strm): fix the name and type issue * fix(strm): update version
1 parent 3989d35 commit 4c0916b

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

drivers/strm/driver.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func (d *Strm) Init(ctx context.Context) error {
9696
}
9797
}
9898

99-
if d.Version != 3 {
99+
if d.Version != 4 {
100100
types := strings.Split("mp4,mkv,flv,avi,wmv,ts,rmvb,webm,mp3,flac,aac,wav,ogg,m4a,wma,alac", ",")
101101
for _, ext := range types {
102102
if _, ok := d.supportSuffix[ext]; !ok {
@@ -109,12 +109,12 @@ func (d *Strm) Init(ctx context.Context) error {
109109
types = strings.Split("ass,srt,vtt,sub,strm", ",")
110110
for _, ext := range types {
111111
if _, ok := d.downloadSuffix[ext]; !ok {
112-
d.supportSuffix[ext] = struct{}{}
112+
d.downloadSuffix[ext] = struct{}{}
113113
downloadTypes = append(downloadTypes, ext)
114114
}
115115
}
116116
d.DownloadFileTypes = strings.Join(downloadTypes, ",")
117-
d.Version = 3
117+
d.Version = 4
118118
}
119119
return nil
120120
}

drivers/strm/util.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package strm
33
import (
44
"context"
55
"fmt"
6-
76
stdpath "path"
87
"strings"
98

@@ -69,11 +68,12 @@ func (d *Strm) convert2strmObjs(ctx context.Context, reqPath string, objs []mode
6968
if !obj.IsDir() {
7069
path = stdpath.Join(reqPath, obj.GetName())
7170
ext := strings.ToLower(utils.Ext(name))
71+
sourceExt := utils.SourceExt(name)
7272
if _, ok := d.downloadSuffix[ext]; ok {
7373
size = obj.GetSize()
7474
} else if _, ok := d.supportSuffix[ext]; ok {
7575
id = "strm"
76-
name = strings.TrimSuffix(name, ext) + "strm"
76+
name = strings.TrimSuffix(name, sourceExt) + "strm"
7777
size = int64(len(d.getLink(ctx, path)))
7878
} else {
7979
continue

pkg/utils/path.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,15 @@ func IsSubPath(path string, subPath string) bool {
4444
}
4545

4646
func Ext(path string) string {
47+
return strings.ToLower(SourceExt(path))
48+
}
49+
50+
func SourceExt(path string) string {
4751
ext := stdpath.Ext(path)
4852
if len(ext) > 0 && ext[0] == '.' {
4953
ext = ext[1:]
5054
}
51-
return strings.ToLower(ext)
55+
return ext
5256
}
5357

5458
func EncodePath(path string, all ...bool) string {

0 commit comments

Comments
 (0)