mirror of https://github.com/Xhofe/alist
feat(aliyundrive_open): support `livp` format file download (close #4890)
parent
c9ea9bce81
commit
1dc1dd1f07
|
@ -2,6 +2,7 @@ package aliyundrive_open
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
@ -35,6 +36,9 @@ func (d *AliyundriveOpen) GetAddition() driver.Additional {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *AliyundriveOpen) Init(ctx context.Context) error {
|
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)
|
res, err := d.request("/adrive/v1.0/user/getDriveInfo", http.MethodPost, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -80,6 +84,12 @@ func (d *AliyundriveOpen) link(ctx context.Context, file model.Obj) (*model.Link
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
url := utils.Json.Get(res, "url").ToString()
|
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
|
exp := time.Hour
|
||||||
return &model.Link{
|
return &model.Link{
|
||||||
URL: url,
|
URL: url,
|
||||||
|
|
|
@ -16,6 +16,7 @@ type Addition struct {
|
||||||
RemoveWay string `json:"remove_way" required:"true" type:"select" options:"trash,delete"`
|
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"`
|
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"`
|
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
|
AccessToken string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue