Skip to content

✨ feat: 利用配置的解锁服务获取下载链接#761

Merged
imsyy merged 8 commits into
devfrom
dev-download
Jan 24, 2026
Merged

✨ feat: 利用配置的解锁服务获取下载链接#761
imsyy merged 8 commits into
devfrom
dev-download

Conversation

@kazukokawagawa
Copy link
Copy Markdown
Collaborator

No description provided.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @kazukokawagawa, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此拉取请求引入了一项新功能,允许用户通过配置的解锁服务获取歌曲下载链接。这一功能在用户界面中以一个可切换的设置项呈现,并优先于现有的默认下载方式。它旨在为用户提供更多获取高质量下载资源的途径,并增强了下载逻辑的灵活性和鲁棒性。

Highlights

  • 新增解锁接口下载功能: 引入了一个新功能,允许用户通过配置的解锁服务获取歌曲下载链接,此方式将优先于默认下载方式。
  • 用户界面设置: 在设置页面新增了一个名为“使用解锁接口下载”的开关,用户可以手动启用或禁用此功能,并带有“Beta”标签。
  • 下载逻辑优化: 下载管理器现在会在尝试获取标准下载链接之前,优先检查是否启用了解锁接口下载。如果启用,它将并发请求所有已配置的解锁服务以获取下载链接。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

这次的 Pull Request 新增了“利用配置的解锁服务获取下载链接”的功能,这是一个很棒的增强。代码实现整体上很可靠,在 UI 上添加了新设置,并在 DownloadManager 中实现了相应逻辑。我主要在 DownloadManager.ts 中发现了两个可以改进的地方,以提高代码的健壮性:一个是处理歌手信息时可能存在的运行时错误,另一个是关于如何更可靠地从 URL 中检测文件类型。总的来说,这项新功能的添加工作做得很好。

Comment thread src/core/resource/DownloadManager.ts Outdated
Comment on lines +268 to +269
const artist = Array.isArray(song.artists) ? song.artists[0].name : song.artists;
const keyWord = song.name + "-" + artist;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

获取歌手名的方式存在风险。如果 song.artists 是一个空数组 []song.artists[0] 会是 undefined,此时访问 .name 属性会抛出 TypeError,导致下载流程中断。
建议使用可选链(?.)和空值合并运算符(??)或逻辑或(||)来安全地获取歌手名,避免潜在的运行时错误。

const artist = (Array.isArray(song.artists) ? song.artists[0]?.name : song.artists) || "";
const keyWord = `${song.name}-${artist}`;

这样可以确保 artist 总是一个字符串,即使 song.artists 是空数组或 song.artists[0].name 不存在。

Suggested change
const artist = Array.isArray(song.artists) ? song.artists[0].name : song.artists;
const keyWord = song.name + "-" + artist;
const artist = (Array.isArray(song.artists) ? song.artists[0]?.name : song.artists) || "";
const keyWord = `${song.name}-${artist}`;

Comment thread src/core/resource/DownloadManager.ts Outdated
Comment on lines +289 to +294
// 尝试推断类型
if (url.includes(".flac")) type = "flac";
else if (url.includes(".ogg")) type = "ogg";
else if (url.includes(".wav")) type = "wav";
else if (url.includes(".m4a")) type = "m4a";
else type = "mp3";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

使用 url.includes(".ext") 来推断文件类型不够健壮。如果 URL 的其他部分(如查询参数)包含了 ".flac" 等字符串,可能会导致错误的类型推断。例如 .../file.mp3?param=.flac

建议通过解析 URL 的路径名来获取文件扩展名,这样更准确可靠。

// 尝试推断类型
const extensionMatch = url.match(/\.([a-z0-9]+)(?:[?#]|$)/i);
const extension = extensionMatch ? extensionMatch[1].toLowerCase() : null;
switch (extension) {
  case "flac":
  case "ogg":
  case "wav":
  case "m4a":
    type = extension;
    break;
  default:
    type = "mp3";
}

这个正则表达式会从 URL 中提取最后一个 . 之后的文件扩展名,并忽略查询字符串和哈希,从而更准确地判断文件类型。

                  // 尝试推断类型
                  const extensionMatch = url.match(/\.([a-z0-9]+)(?:[?#]|$)/i);
                  const extension = extensionMatch ? extensionMatch[1].toLowerCase() : null;
                  switch (extension) {
                    case "flac":
                    case "ogg":
                    case "wav":
                    case "m4a":
                      type = extension;
                      break;
                    default:
                      type = "mp3";
                  }

@MoeFurina
Copy link
Copy Markdown
Contributor

MoeFurina commented Jan 24, 2026

如果说可以使用配置的解锁服务获取下载链接, 这个限制应当被解除
image

@kazukokawagawa
Copy link
Copy Markdown
Collaborator Author

如果说可以使用配置的解锁服务获取下载链接, 这个限制应当被解除 image

对不起 我们不是破解软件 这个限制不会 而且也不可能去除

@imsyy imsyy merged commit 43476bb into dev Jan 24, 2026
4 checks passed
@kazukokawagawa kazukokawagawa deleted the dev-download branch January 24, 2026 11:14
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