-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
Conversation
Walkthrough此PR为Doubao驱动增加了 Changes
|
确实可以解决文件名编码问题,但是我测试了不同大小的图片,通过 同时,doubao_share驱动应该也可以进行同样的修改 |
麻烦提供一下测试的图片,我这边试下来不会压缩 |
|
感谢提供测试文件,试下来新接口 PNG 仍存在压缩现象;JPG 没有出现压缩,MD5校验也没有发生变化,但下载链接文件名有转码的标记,不排除后续会加上压缩。 |
同时测试了,doubao_share驱动无法使用这个接口,响应200,但是data返回为null 看起来可以至少可以解决302模式下文件名编码问题,还是值得更改的👍 这样的话,doubao驱动应该可以统一下载地址的获取接口了, 不用像之前根据文件类型区分开了 |
There was a problem hiding this 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 | ||
} | ||
|
There was a problem hiding this comment.
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.
if len(r.Data.DownloadInfos) == 0 { | |
return nil, errors.New("no download info available") | |
} |
Copilot uses AI. Check for mistakes.
增加
get_download_info
这个 API,目前网页端默认使用,返回的链接带有文件名参数,不会出现文件名被编码的问题,支持获取视频文件的下载链接,获取到图片的下载地址也不会被压缩(不包括 PNG)。Note: 文件名参数:
?attname=