From fce872bc1b80be5cb31e7268c42811022cf70ed8 Mon Sep 17 00:00:00 2001 From: Andy Hsu Date: Fri, 14 Jul 2023 14:43:40 +0800 Subject: [PATCH] feat(123): thumbnail support (#3953) --- drivers/123/types.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/123/types.go b/drivers/123/types.go index 424189a9a68..bc7cbf3d5b2 100644 --- a/drivers/123/types.go +++ b/drivers/123/types.go @@ -1,7 +1,10 @@ package _123 import ( + "net/url" + "path" "strconv" + "strings" "time" "github.com/alist-org/alist/v3/internal/model" @@ -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 { //