Skip to content

Commit 991da7d

Browse files
Seven66677731xrgzs
andauthored
feat(strm): add local mode (#885)
* feat(strm): add local mode * Update drivers/strm/meta.go Co-authored-by: MadDogOwner <[email protected]> Signed-off-by: Seven <[email protected]> * feat(strm): local mode add sign --------- Signed-off-by: Seven <[email protected]> Co-authored-by: MadDogOwner <[email protected]>
1 parent a498091 commit 991da7d

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

drivers/strm/meta.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ type Addition struct {
1010
SiteUrl string `json:"siteUrl" type:"text" required:"false" help:"The prefix URL of the strm file"`
1111
FilterFileTypes string `json:"filterFileTypes" type:"text" default:"strm" required:"false" help:"Supports suffix name of strm file"`
1212
EncodePath bool `json:"encodePath" default:"true" required:"true" help:"encode the path in the strm file"`
13+
LocalModel bool `json:"localModel" default:"false" help:"enable local mode"`
1314
}
1415

1516
var config = driver.Config{

drivers/strm/util.go

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,22 +127,29 @@ func (d *Strm) list(ctx context.Context, dst, sub string, args *fs.ListArgs) ([]
127127
}
128128

129129
func (d *Strm) getLink(ctx context.Context, path string) string {
130+
var encodePath string
131+
if d.EncodePath {
132+
encodePath = utils.EncodePath(path, true)
133+
}
134+
if d.EnableSign {
135+
signPath := sign.Sign(path)
136+
if len(encodePath) > 0 {
137+
path = fmt.Sprintf("%s?sign=%s", encodePath, signPath)
138+
} else {
139+
path = fmt.Sprintf("%s?sign=%s", path, signPath)
140+
}
141+
}
142+
if d.LocalModel {
143+
return path
144+
}
130145
apiUrl := d.SiteUrl
131146
if len(apiUrl) > 0 {
132147
apiUrl = strings.TrimSuffix(apiUrl, "/")
133148
} else {
134149
apiUrl = common.GetApiUrl(ctx)
135150
}
136151

137-
if d.EncodePath {
138-
path = utils.EncodePath(path, true)
139-
}
140-
if !d.EnableSign {
141-
return fmt.Sprintf("%s/d%s", apiUrl, path)
142-
}
143-
144-
return fmt.Sprintf("%s/d%s?sign=%s",
152+
return fmt.Sprintf("%s/d%s",
145153
apiUrl,
146-
path,
147-
sign.Sign(path))
154+
path)
148155
}

0 commit comments

Comments
 (0)