Skip to content

feat: --lrc to export sibling .lrc files alongside audio#2

Open
CPbianma wants to merge 1 commit into
Sophomoresty:mainfrom
CPbianma:feat/lrc-export
Open

feat: --lrc to export sibling .lrc files alongside audio#2
CPbianma wants to merge 1 commit into
Sophomoresty:mainfrom
CPbianma:feat/lrc-export

Conversation

@CPbianma

@CPbianma CPbianma commented Jun 2, 2026

Copy link
Copy Markdown

Summary

External-lyric-aware players (PotPlayer, foobar2000, car head units,
…) expect a same-stem .lrc file next to the audio. The fetched LRC
is already embedded as a FLAC LYRICS tag; this just dumps it as
UTF-8 to <stem>.lrc when --lrc is passed.

Exposed on download, decrypt, and album. The write_metadata
return dict gains an "lrc" boolean indicating whether the side-car
was written. Translation, if QQ returns one, is appended to the
.lrc the same way it's embedded in the tag.

Note on ordering

This PR is independent and safe to merge on its own, but on the
download command the side-car only materializes once the companion
fix PR (#1) is merged — without that fix, fetch_metadata returns
None for most mids and we never reach the write-lyrics branch. On
album the side-car works today.

Risk

  • write_metadata signature is backwards-compatible (new param is
    keyword-only with a default).
  • New return-dict key "lrc" is purely additive.
  • No new dependencies.

Test

qmdec album <singer_mid> -o ./out -q flac --lrc on this branch
produces .lrc files alongside each .flac. The generated .lrc is
valid ([ti]/[ar]/[al]/[mm:ss.xx]) and UTF-8.

With both PRs applied, qmdec download "周杰伦 晴天" -o ./out -q flac --lrc produces a 2.6 KB .lrc alongside the FLAC, content matches
the FLAC's embedded LYRICS tag verbatim.


中文说明

外挂歌词播放器 (PotPlayer、foobar2000、车机等) 习惯读取与音频文件同
名的 .lrc。我们已经把歌词写进 FLAC 的 LYRICS 标签里了; 这个 PR 只
是在 --lrc 开关打开时额外把它落到 <stem>.lrc (UTF-8)。

download / decrypt / album 三条命令都加了 --lrc 开关。
write_metadata 返回 dict 新增 "lrc" 字段标记是否落盘。如果 QQ
接口返回了翻译, .lrc 末尾也会拼接, 跟内嵌标签一致。

关于合并顺序

本 PR 独立可合, 但 download 命令上的 .lrc 落盘需要先合配套的
fix PR (#1)
—— 没那个 fix, fetch_metadata 对大多数 mid 返回 None,
连写歌词的分支都不会走到。album 命令上目前就能用。

External-lyric-aware players (PotPlayer, foobar2000, car head units,
etc.) expect a same-stem .lrc file next to the audio. The fetched LRC
is already embedded as a FLAC LYRICS tag; this just dumps it as UTF-8
to <stem>.lrc when --lrc is passed.

Exposed on `download`, `decrypt`, and `album`. The write_metadata
return dict gains an "lrc" boolean indicating whether the side-car was
written. Translation, if QQ returns one, is appended to the .lrc the
same way it's embedded in the tag.

Note: on `download` this currently doesn't fire because the existing
fetch_metadata(song_mid) path silently returns None for most mids
(search endpoint misbehavior). That's a separate bug filed as a
companion PR; once that's merged --lrc kicks in for `download` too.
On `album` it works today.
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.

1 participant