Skip to content

feat(doubao): add get_download_info API and download_api option #8428

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

Merged
merged 1 commit into from
Apr 27, 2025

Conversation

xrgzs
Copy link
Contributor

@xrgzs xrgzs commented Apr 23, 2025

增加 get_download_info 这个 API,目前网页端默认使用,返回的链接带有文件名参数,不会出现文件名被编码的问题,支持获取视频文件的下载链接,获取到图片的下载地址也不会被压缩(不包括 PNG)。

Note: 文件名参数:?attname=

@xrgzs xrgzs changed the title feat(doubao):add get_download_info API and download_api option feat(doubao): add get_download_info API and download_api option Apr 23, 2025
Copy link

Walkthrough

此PR为Doubao驱动增加了get_download_info API和download_api选项,默认返回带有文件名参数的链接,解决文件名被编码的问题,并支持获取视频文件的下载链接。

Changes

文件 摘要
drivers/doubao/driver.go 添加了get_download_info API和download_api选项,调整了下载链接获取的逻辑。
drivers/doubao/meta.go 增加了DownloadApi字段以支持新的API选项。
drivers/doubao/types.go 定义了GetDownloadInfoResp结构以支持新的API响应。

@anobodys
Copy link
Contributor

anobodys commented Apr 23, 2025

增加 get_download_info 这个 API,目前网页端默认使用,返回的链接带有文件名参数,不会出现文件名被编码的问题,支持获取视频文件的下载链接,获取到图片的下载地址也不会被压缩。

Note: 文件名参数:?attname=

Close: #8366

确实可以解决文件名编码问题,但是我测试了不同大小的图片,通过get_download_info接口获取到的地址下载,图片还是被压缩过的


同时,doubao_share驱动应该也可以进行同样的修改

@xrgzs
Copy link
Contributor Author

xrgzs commented Apr 23, 2025

图片还是被压缩过的

麻烦提供一下测试的图片,我这边试下来不会压缩

@anobodys
Copy link
Contributor

图片还是被压缩过的

麻烦提供一下测试的图片,我这边试下来不会压缩

https://www.doubao.com/drive/s/c734b3a1d7a6b57d

@xrgzs
Copy link
Contributor Author

xrgzs commented Apr 23, 2025

https://www.doubao.com/drive/s/c734b3a1d7a6b57d

感谢提供测试文件,试下来新接口 PNG 仍存在压缩现象;JPG 没有出现压缩,MD5校验也没有发生变化,但下载链接文件名有转码的标记,不排除后续会加上压缩。

@anobodys
Copy link
Contributor

https://www.doubao.com/drive/s/c734b3a1d7a6b57d

感谢提供测试文件,试下来新接口 PNG 仍存在压缩现象;JPG 没有出现压缩,MD5校验也没有发生变化,但下载链接文件名有转码的标记,不排除后续会加上压缩。

同时测试了,doubao_share驱动无法使用这个接口,响应200,但是data返回为null

看起来可以至少可以解决302模式下文件名编码问题,还是值得更改的👍

这样的话,doubao驱动应该可以统一下载地址的获取接口了, 不用像之前根据文件类型区分开了

@xhofe xhofe requested a review from Copilot April 27, 2025 11:59
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces the get_download_info API functionality for the Doubao driver to support unencoded file names in download links, along with adding a configuration option to choose between download API endpoints.

  • Added a new response type (GetDownloadInfoResp) to parse the download information.
  • Updated meta configuration to include the "DownloadApi" option.
  • Modified driver logic to conditionally handle API calls based on the selected download API.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
drivers/doubao/types.go Added new response structure for the get_download_info API
drivers/doubao/meta.go Introduced new DownloadApi configuration option in the metadata
drivers/doubao/driver.go Implemented switch-case logic to support the new download API option

req.SetBody(base.Json{
"key": u.Key,
"node_id": file.GetID(),
"requests": []base.Json{{"node_id": file.GetID()}},
})
}, &r)
if err != nil {
return nil, err
}

Copy link
Preview

Copilot AI Apr 27, 2025

Choose a reason for hiding this comment

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

Ensure that r.Data.DownloadInfos is not empty before accessing index 0 to prevent a potential panic.

Suggested change
if len(r.Data.DownloadInfos) == 0 {
return nil, errors.New("no download info available")
}

Copilot uses AI. Check for mistakes.

@xhofe xhofe merged commit b2b91a9 into AlistGo:main Apr 27, 2025
24 checks passed
@xrgzs xrgzs deleted the feat/doubao branch April 27, 2025 16:12
@dgscyg dgscyg mentioned this pull request May 26, 2025
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants