fix(metadata): tag with correct song using known-good song_info#1
Open
CPbianma wants to merge 1 commit into
Open
fix(metadata): tag with correct song using known-good song_info#1CPbianma wants to merge 1 commit into
CPbianma wants to merge 1 commit into
Conversation
…by-mid
The download/decrypt paths previously called fetch_metadata(song_mid),
which round-trips QQ Music's search endpoint with the mid as the
search keyword. When that mid is not the top search hit, the endpoint
silently returns an unrelated song's metadata — so the file either
gets tagged "metadata not found" or, worse, gets tagged with someone
else's song info.
Fix: thread the raw song dict from search_songs() through write_metadata
via a new song_info parameter, and have write_metadata build meta via
fetch_metadata_from_album_song() before falling back to the legacy
path. As a belt-and-braces guard, fetch_metadata() now rejects results
whose mid doesn't match the requested one.
Repro: `qmdec download "周杰伦 晴天" -o ./out -q flac` previously
returned `"tag": {"ok": false, "error": "metadata not found"}` even
with a valid VIP cookie. After this fix the FLAC gets full title /
artist / album / year / track / lyrics / cover.
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
The download/decrypt paths previously called
fetch_metadata(song_mid),which round-trips QQ Music's search endpoint with the mid as the
keyword. When that mid isn't the top search hit, the endpoint silently
returns an unrelated song's metadata — so the file is either tagged
"metadata not found" or, worse, tagged with someone else's song info.
This PR threads the raw song dict from
search_songs()throughwrite_metadatavia a newsong_infoparameter, and haswrite_metadatabuild meta viafetch_metadata_from_album_song()before falling back to the legacy path. As a belt-and-braces guard,
fetch_metadata()now rejects results whose mid doesn't match therequested one.
Reproducing the bug
QQ Music desktop running, logged in with VIP, then:
Before this PR, the returned JSON contains
"tag": {"ok": false, "error": "metadata not found"}and the FLAC hasno title/artist/album/lyrics/cover.
After this PR every field fills in, matching what
qmdec albumalready produces.
Risk
search_songsnow carries the raw API dict in each returned item.Code that iterates result entries by their documented keys is
unaffected.
write_metadatasignature is backwards-compatible (all new paramsare keyword-only with defaults).
Test
Smoke-tested on Win11 / Python 3.14 against a live VIP account.
After the fix,
qmdec download "周杰伦 晴天" -o ./out -q flacproducestag.ok=trueand FLAC inspection shows full title / artist / album /year / track / disc / lyrics / 81 KB JPEG artwork.
中文说明
download/decrypt路径之前调fetch_metadata(song_mid)是把 mid当成关键词去走 QQ 音乐的搜索接口。如果这个 mid 不是搜索热门首条,
接口会静默返回另一首歌的元数据 —— 结果要么报 "metadata not found",
要么更糟, 把别人的元信息写进了你的文件。
本 PR 让
search_songs()返回的原始 song dict 透传到write_metadata(新增
song_info参数), 由fetch_metadata_from_album_song()直接构造meta, 绕过有问题的搜索接口。同时
fetch_metadata()加一道 mid 一致性校验作为兜底。
复现
QQ 音乐桌面端登录 VIP 后:
修复前 JSON 返回
"tag": {"ok": false, "error": "metadata not found"},FLAC 没有任何标签。修复后所有字段齐全, 跟
qmdec album表现一致。