Skip to content

Commit

Permalink
feat(123): thumbnail support (#3953)
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Jul 14, 2023
1 parent df6c4c8 commit fce872b
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions drivers/123/types.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package _123

import (
"net/url"
"path"
"strconv"
"strings"
"time"

"github.com/alist-org/alist/v3/internal/model"
Expand Down Expand Up @@ -42,7 +45,30 @@ func (f File) GetID() string {
return strconv.FormatInt(f.FileId, 10)
}

func (f File) Thumb() string {
if f.DownloadUrl == "" {
return ""
}
du, err := url.Parse(f.DownloadUrl)
if err != nil {
return ""
}
du.Path = strings.TrimSuffix(du.Path, "_24_24") + "_70_70"
query := du.Query()
query.Set("w", "70")
query.Set("h", "70")
if !query.Has("type") {
query.Set("type", strings.TrimPrefix(path.Base(f.FileName), "."))
}
if !query.Has("trade_key") {
query.Set("trade_key", "123pan-thumbnail")
}
du.RawQuery = query.Encode()
return du.String()
}

var _ model.Obj = (*File)(nil)
var _ model.Thumb = (*File)(nil)

//func (f File) Thumb() string {
//
Expand Down

0 comments on commit fce872b

Please sign in to comment.