From 7f35dc6ade0129bd5bf7ded90bfad608c4d939be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=AE=E5=87=89?= <927625802@qq.com> Date: Tue, 30 Nov 2021 16:27:23 +0800 Subject: [PATCH] :sparkles: add onedrive thumbnail --- drivers/onedrive.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/onedrive.go b/drivers/onedrive.go index 71b14558..71f79ed0 100644 --- a/drivers/onedrive.go +++ b/drivers/onedrive.go @@ -104,6 +104,11 @@ type OneFile struct { File struct { MimeType string `json:"mimeType"` } `json:"file"` + Thumbnails []struct{ + Medium struct{ + Url string `json:"url"` + } `json:"medium"` + } `json:"thumbnails"` } type OneFiles struct { @@ -126,6 +131,9 @@ func (driver Onedrive) FormatFile(file *OneFile) *model.File { Driver: driver.Config().Name, Url: file.Url, } + if len(file.Thumbnails) > 0 { + f.Thumbnail = file.Thumbnails[0].Medium.Url + } if file.File.MimeType == "" { f.Type = conf.FOLDER } else { @@ -136,9 +144,9 @@ func (driver Onedrive) FormatFile(file *OneFile) *model.File { func (driver Onedrive) GetFiles(account *model.Account, path string) ([]OneFile, error) { var res []OneFile - nextLink := driver.GetMetaUrl(account, false, path) + "/children" + nextLink := driver.GetMetaUrl(account, false, path) + "/children?$expand=thumbnails" if account.OrderBy != "" { - nextLink += fmt.Sprintf("?orderby=%s", account.OrderBy) + nextLink += fmt.Sprintf("&orderby=%s", account.OrderBy) if account.OrderDirection != "" { nextLink += fmt.Sprintf(" %s", account.OrderDirection) }