Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

阿里云盘下载优先使用cdn直链 #6645

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion .github/workflows/auto_lang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Checkout alist-web
uses: actions/checkout@v4
with:
repository: 'alist-org/alist-web'
repository: 'qy527145/alist-web'
ref: main
persist-credentials: false
fetch-depth: 0
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: [ 'main' ]
pull_request:
branches: [ 'main' ]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand Down Expand Up @@ -45,4 +46,4 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: alist_${{ env.SHA }}
path: dist
path: dist
14 changes: 7 additions & 7 deletions .github/workflows/build_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: build_docker

Copy link
Collaborator

Choose a reason for hiding this comment

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

请不要修改workflow文件

Copy link
Author

Choose a reason for hiding this comment

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

我再单独加个分支用于pr吧,好像排除不了了

on:
push:
branches: [ main ]
分支: [ main ]
pull_request:
branches: [ main ]
分支: [ main ]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand All @@ -22,13 +22,13 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
images: xhofe/alist
images: wmymz/alist

- name: Docker meta with ffmpeg
id: meta-ffmpeg
uses: docker/metadata-action@v5
with:
images: xhofe/alist
images: wmymz/alist
flavor: |
suffix=-ffmpeg,onlatest=true

Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
if: github.event_name == 'push'
uses: docker/login-action@v3
with:
username: xhofe
username: wmymz
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
Expand Down Expand Up @@ -95,7 +95,7 @@ jobs:
- name: Checkout repo
uses: actions/checkout@v4
with:
repository: alist-org/with_aria2
repository: qy527145/with_aria2
ref: main
persist-credentials: false
fetch-depth: 0
Expand All @@ -111,4 +111,4 @@ jobs:
with:
github_token: ${{ secrets.MY_TOKEN }}
branch: main
repository: alist-org/with_aria2
repository: qy527145/with_aria2
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
- name: Checkout repo
uses: actions/checkout@v4
with:
repository: alist-org/desktop-release
repository: qy527145/desktop-release
ref: main
persist-credentials: false
fetch-depth: 0
Expand All @@ -72,4 +72,4 @@ jobs:
with:
github_token: ${{ secrets.MY_TOKEN }}
branch: main
repository: alist-org/desktop-release
repository: qy527145/desktop-release
4 changes: 2 additions & 2 deletions .github/workflows/release_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
- name: Checkout repo
uses: actions/checkout@v4
with:
repository: alist-org/with_aria2
repository: qy527145/with_aria2
ref: main
persist-credentials: false
fetch-depth: 0
Expand All @@ -105,4 +105,4 @@ jobs:
with:
github_token: ${{ secrets.MY_TOKEN }}
branch: main
repository: alist-org/with_aria2
repository: qy527145/with_aria2
13 changes: 11 additions & 2 deletions drivers/aliyundrive/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,26 @@ func (d *AliDrive) Link(ctx context.Context, file model.Obj, args model.LinkArgs
"file_id": file.GetID(),
"expire_sec": 14400,
}
res, err, _ := d.request("https://api.alipan.com/v2/file/get_download_url", http.MethodPost, func(req *resty.Request) {
res, err, _ := d.request("https://bj29.api.aliyunpds.com/v2/file/get_download_url", http.MethodPost, func(req *resty.Request) {
Copy link
Contributor

@SeanHeuc SeanHeuc Jun 27, 2024

Choose a reason for hiding this comment

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

replacing the official url with a third-party one is never a good practice. Alipan official could change this url anytime, and then many user will have trouble use this driver.
please put this url as an option if this can provide acceleration benefit.

Copy link
Author

Choose a reason for hiding this comment

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

这并不是一个第三方的url,相反,它是阿里云盘的上游服务pds(阿里云的一个云服务产品),阿里云盘在此基础上封装了一层(可能伴随着一些接口信息的阉割),一般来说,它比阿里云盘的接口更可靠。

Copy link
Contributor

Choose a reason for hiding this comment

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

as long as it's not an official url in the Aliyun-Open doc, it's stability is not guaranteed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

就像 @SeanHeuc 说的,请将其作为一个选项 而不是直接修改

Copy link
Author

Choose a reason for hiding this comment

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

不太熟悉go语言,回头看看go的语法,有时间再改改

req.SetBody(data)
}, nil)
if err != nil {
return nil, err
}
// 尝试获取 cdn_url
cdnURL := utils.Json.Get(res, "cdn_url").ToString()
var downloadURL string
if cdnURL != "" {
downloadURL = cdnURL
} else {
// 如果 cdn_url 为空,则获取 url
downloadURL = utils.Json.Get(res, "url").ToString()
}
return &model.Link{
Header: http.Header{
"Referer": []string{"https://www.alipan.com/"},
},
URL: utils.Json.Get(res, "url").ToString(),
URL: downloadURL,
}, nil
}

Expand Down