更换网易云请求api - #147
Conversation
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
|
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.
| extra = { | ||
| "info": audio_info, | ||
| "lyric": lyric, | ||
| "lyric": text, |
There was a problem hiding this comment.
issue (bug_risk): 将 lyric 字段重复用于混合的元数据和歌词,可能会破坏那些期望获得纯歌词文本的使用方。
extra["lyric"] 之前是原始歌词,现在则变成了把 audio_info 和歌词混在一起的格式化文本。任何假定 extra["lyric"] 为纯歌词的调用方或 UI 都可能行为异常。如果你需要一个合并后的文本字段,建议新增一个键(例如 "description" / "full_text"),并保持 "lyric" 只包含歌词,除非你已经确认所有使用方都能处理这种新格式。
Original comment in English
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.
| 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, |
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: