feat: 网易云增加音质重试功能 - #147
Merged
Merged
Conversation
Contributor
Reviewer's Guide更新 NetEase Cloud Music 解析器,以优先选择更高音质的音频、丰富元数据和日志,并更改歌词与额外信息在结果中的封装方式。 更新后的 NetEase 音乐解析流程时序图sequenceDiagram
participant Parser as NeteaseParser
participant NeteaseAPI as NeteaseAPI
Parser->>NeteaseAPI: fetch(getSongInfo, id)
NeteaseAPI-->>Parser: song
Parser->>NeteaseAPI: fetch(getSongLyric, id)
NeteaseAPI-->>Parser: lyric
loop try_audio_levels
Parser->>NeteaseAPI: fetch(getSongUrl, id, level=lossless|standard)
alt url_available
NeteaseAPI-->>Parser: url_data(url, size)
Parser-->>Parser: set audio_url, audio_level, audio_size, audio_type
Parser-->>Parser: break
else error_or_no_url
NeteaseAPI-->>Parser: error_or_empty
Parser-->>Parser: log warning
end
end
alt audio_url_missing
Parser-->>Parser: raise ParseException
else audio_url_found
Parser-->>Parser: create_audio(audio_url, duration, title, artist)
Parser-->>Parser: create_image(cover_url)
Parser-->>Parser: build audio_info(audio_level, audio_size, audio_type)
Parser-->>Parser: build lyric_text(audio_info, lyric)
Parser-->>Parser: result(contents, extra_info)
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your Experience前往你的 dashboard 来:
Getting HelpOriginal review guide in EnglishReviewer's GuideUpdates the NetEase Cloud Music parser to prefer higher quality audio, enrich metadata and logging, and change how lyric and extra info are packaged in the result. Sequence diagram for updated NetEase music parsing flowsequenceDiagram
participant Parser as NeteaseParser
participant NeteaseAPI as NeteaseAPI
Parser->>NeteaseAPI: fetch(getSongInfo, id)
NeteaseAPI-->>Parser: song
Parser->>NeteaseAPI: fetch(getSongLyric, id)
NeteaseAPI-->>Parser: lyric
loop try_audio_levels
Parser->>NeteaseAPI: fetch(getSongUrl, id, level=lossless|standard)
alt url_available
NeteaseAPI-->>Parser: url_data(url, size)
Parser-->>Parser: set audio_url, audio_level, audio_size, audio_type
Parser-->>Parser: break
else error_or_no_url
NeteaseAPI-->>Parser: error_or_empty
Parser-->>Parser: log warning
end
end
alt audio_url_missing
Parser-->>Parser: raise ParseException
else audio_url_found
Parser-->>Parser: create_audio(audio_url, duration, title, artist)
Parser-->>Parser: create_image(cover_url)
Parser-->>Parser: build audio_info(audio_level, audio_size, audio_type)
Parser-->>Parser: build lyric_text(audio_info, lyric)
Parser-->>Parser: result(contents, extra_info)
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - 我发现了 1 个问题,并给出了一些整体反馈:
- 现在
extra["lyric"]负载中包含了音频信息和格式化内容,而不再只是原始歌词字符串,这可能会破坏那些只期望纯歌词文本的使用方;建议为格式化文本新增一个字段,并将lyric保持为原始内容。 - 新增的
audio_info中的audio_size直接来自url_data.get("size"),这很可能是字节数或未格式化的值;建议将其规范化为一个易读的大小(类似之前的audio.get_display_size()),以保持展示形式一致。
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `extra["lyric"]` payload now includes audio info and formatting instead of just the raw lyrics string, which may break any consumer that expects only plain lyrics; consider adding a new field for the formatted text and keeping `lyric` as the original content.
- The new `audio_size` in `audio_info` is taken directly from `url_data.get("size")`, which is likely bytes or an unformatted value; consider normalizing this to a human-readable size (similar to the previous `audio.get_display_size()`) to keep the display consistent.
## Individual Comments
### Comment 1
<location path="src/nonebot_plugin_parser_lite/parsers/netease.py" line_range="182" />
<code_context>
extra = {
"info": audio_info,
- "lyric": lyric,
+ "lyric": text,
+ "type": "audio",
+ "type_tag": "音乐",
</code_context>
<issue_to_address>
**issue (bug_risk):** Reusing the `lyric` field for mixed metadata and lyrics may break consumers expecting plain lyric text.
`extra["lyric"]` used to be raw lyrics, but now holds formatted text mixing `audio_info` and lyrics. Any callers or UIs assuming plain lyrics may misbehave. If you need a combined text field, add a new key (e.g. `"description"` / `"full_text"`) and keep `"lyric"` as lyrics-only, unless you’ve confirmed all consumers can handle the new format.
</issue_to_address>Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Original comment in English
Hey - I've found 1 issue, and left some high level feedback:
- The
extra["lyric"]payload now includes audio info and formatting instead of just the raw lyrics string, which may break any consumer that expects only plain lyrics; consider adding a new field for the formatted text and keepinglyricas the original content. - The new
audio_sizeinaudio_infois taken directly fromurl_data.get("size"), which is likely bytes or an unformatted value; consider normalizing this to a human-readable size (similar to the previousaudio.get_display_size()) to keep the display consistent.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `extra["lyric"]` payload now includes audio info and formatting instead of just the raw lyrics string, which may break any consumer that expects only plain lyrics; consider adding a new field for the formatted text and keeping `lyric` as the original content.
- The new `audio_size` in `audio_info` is taken directly from `url_data.get("size")`, which is likely bytes or an unformatted value; consider normalizing this to a human-readable size (similar to the previous `audio.get_display_size()`) to keep the display consistent.
## Individual Comments
### Comment 1
<location path="src/nonebot_plugin_parser_lite/parsers/netease.py" line_range="182" />
<code_context>
extra = {
"info": audio_info,
- "lyric": lyric,
+ "lyric": text,
+ "type": "audio",
+ "type_tag": "音乐",
</code_context>
<issue_to_address>
**issue (bug_risk):** Reusing the `lyric` field for mixed metadata and lyrics may break consumers expecting plain lyric text.
`extra["lyric"]` used to be raw lyrics, but now holds formatted text mixing `audio_info` and lyrics. Any callers or UIs assuming plain lyrics may misbehave. If you need a combined text field, add a new key (e.g. `"description"` / `"full_text"`) and keep `"lyric"` as lyrics-only, unless you’ve confirmed all consumers can handle the new format.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
molanp
requested changes
Jun 20, 2026
| lyric = (await self.fetch("getSongLyric", {"id": ncm_id})).get("lrc") | ||
| url_data = await self.fetch("getSongUrl", {"id": ncm_id, "level": "standard"}) | ||
| if not (audio_url := url_data.get("url")): | ||
|
|
| extra = { | ||
| "info": audio_info, | ||
| "lyric": lyric, | ||
| "lyric": text, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by Sourcery
改进网易云音乐歌曲解析,以支持多种音质等级,并在结果中提供更丰富的元数据。
错误修复:
功能增强:
Original summary in English
Summary by Sourcery
Improve NetEase Cloud Music song parsing to support multiple quality levels and richer metadata in the result.
Bug Fixes:
Enhancements: