Skip to content

Commit

Permalink
feat(aliyundrive_open): support livp format file download (close #4890
Browse files Browse the repository at this point in the history
)
  • Loading branch information
xhofe committed Aug 1, 2023
1 parent c9ea9bc commit 1dc1dd1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
10 changes: 10 additions & 0 deletions drivers/aliyundrive_open/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package aliyundrive_open

import (
"context"
"errors"
"fmt"
"net/http"
"time"
Expand Down Expand Up @@ -35,6 +36,9 @@ func (d *AliyundriveOpen) GetAddition() driver.Additional {
}

func (d *AliyundriveOpen) Init(ctx context.Context) error {
if d.LIVPDownloadFormat == "" {
d.LIVPDownloadFormat = "jpeg"
}
res, err := d.request("/adrive/v1.0/user/getDriveInfo", http.MethodPost, nil)
if err != nil {
return err
Expand Down Expand Up @@ -80,6 +84,12 @@ func (d *AliyundriveOpen) link(ctx context.Context, file model.Obj) (*model.Link
return nil, err
}
url := utils.Json.Get(res, "url").ToString()
if url == "" {
if utils.Ext(file.GetName()) != "livp" {
return nil, errors.New("get download url failed: " + string(res))
}
url = utils.Json.Get(res, "streamsUrl", d.LIVPDownloadFormat).ToString()
}
exp := time.Hour
return &model.Link{
URL: url,
Expand Down
21 changes: 11 additions & 10 deletions drivers/aliyundrive_open/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ import (

type Addition struct {
driver.RootID
RefreshToken string `json:"refresh_token" required:"true"`
OrderBy string `json:"order_by" type:"select" options:"name,size,updated_at,created_at"`
OrderDirection string `json:"order_direction" type:"select" options:"ASC,DESC"`
OauthTokenURL string `json:"oauth_token_url" default:"https://api.xhofe.top/alist/ali_open/token"`
ClientID string `json:"client_id" required:"false" help:"Keep it empty if you don't have one"`
ClientSecret string `json:"client_secret" required:"false" help:"Keep it empty if you don't have one"`
RemoveWay string `json:"remove_way" required:"true" type:"select" options:"trash,delete"`
RapidUpload bool `json:"rapid_upload" help:"If you enable this option, the file will be uploaded to the server first, so the progress will be incorrect"`
InternalUpload bool `json:"internal_upload" help:"If you are using Aliyun ECS is located in Beijing, you can turn it on to boost the upload speed"`
AccessToken string
RefreshToken string `json:"refresh_token" required:"true"`
OrderBy string `json:"order_by" type:"select" options:"name,size,updated_at,created_at"`
OrderDirection string `json:"order_direction" type:"select" options:"ASC,DESC"`
OauthTokenURL string `json:"oauth_token_url" default:"https://api.xhofe.top/alist/ali_open/token"`
ClientID string `json:"client_id" required:"false" help:"Keep it empty if you don't have one"`
ClientSecret string `json:"client_secret" required:"false" help:"Keep it empty if you don't have one"`
RemoveWay string `json:"remove_way" required:"true" type:"select" options:"trash,delete"`
RapidUpload bool `json:"rapid_upload" help:"If you enable this option, the file will be uploaded to the server first, so the progress will be incorrect"`
InternalUpload bool `json:"internal_upload" help:"If you are using Aliyun ECS is located in Beijing, you can turn it on to boost the upload speed"`
LIVPDownloadFormat string `json:"livp_download_format" type:"select" options:"jpeg,mov" default:"jpeg"`
AccessToken string
}

var config = driver.Config{
Expand Down

3 comments on commit 1dc1dd1

@earthjasonlin
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When mov format selected, it will download .livp.mov normally. However, when jpeg format selected, it still downloads mov. I've refreshed the storage.

@xhofe
Copy link
Collaborator Author

@xhofe xhofe commented on 1dc1dd1 Aug 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When mov format selected, it will download .livp.mov normally. However, when jpeg format selected, it still downloads mov. I've refreshed the storage.

The download URL of AliyundriveOpen has one hour cache, and there is no way to clear it for the time being. You can only wait for it to expire or restart the program.

@earthjasonlin
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When mov format selected, it will download .livp.mov normally. However, when jpeg format selected, it still downloads mov. I've refreshed the storage.

The download URL of AliyundriveOpen has one hour cache, and there is no way to clear it for the time being. You can only wait for it to expire or restart the program.

OK, Thanks

Please sign in to comment.