Skip to content

lyrics: support 3-decimal millisecond timestamps in LRC parsing - #7001

Merged
snejus merged 1 commit into
beetbox:masterfrom
mlandry:fix/lyrics-millisecond-precision
Sep 11, 2026
Merged

snejus merged 1 commit into
beetbox:masterfrom
mlandry:fix/lyrics-millisecond-precision

Conversation

@mlandry

@mlandry mlandry commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Description

LRCLIB commonly returns LRC timestamps with 3 decimal places ([mm:ss.xxx]). LINE_PARTS_PAT and LRC_TIMESTAMP_PAT strictly expected two digits (\.\d\d), causing verify_synced_lyrics to fail when the final line of a song has millisecond precision and silently fall back to plainLyrics.

Additionally, interior 3-decimal lines had timestamps dropped from ID3 SYLT frames and leaked raw bracketed tags into plain text extraction.

  • Update regexes to accept \.\d{2,3}
  • Parse both 2-digit (cs) and 3-digit (ms) fractions in Lyrics.sylt
  • Add unit tests and changelog entry

To Do

  • Documentation
  • Changelog
  • Tests

@mlandry
mlandry requested a review from a team as a code owner September 7, 2026 20:03
@github-actions github-actions Bot added the lyrics lyrics plugin label Sep 7, 2026
@mlandry
mlandry force-pushed the fix/lyrics-millisecond-precision branch 5 times, most recently from 9376bfa to 58150af Compare September 8, 2026 14:33
@codecov

codecov Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.39%. Comparing base (294b15c) to head (6411f82).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7001      +/-   ##
==========================================
+ Coverage   77.24%   77.39%   +0.14%     
==========================================
  Files         163      163              
  Lines       21840    21841       +1     
  Branches     3370     3370              
==========================================
+ Hits        16871    16904      +33     
+ Misses       4149     4112      -37     
- Partials      820      825       +5     
Files with missing lines Coverage Δ
beets/util/lyrics.py 96.93% <100.00%> (+0.03%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@snejus

snejus commented Sep 8, 2026

Copy link
Copy Markdown
Member

Could you provide a stack trace of a crash?

@mlandry

mlandry commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

Could you provide a stack trace of a crash?

This bug doesn't cause a crash but rather discards synced lyrics that have 3-decimal millisecond timestamps and falls back to plain lyrics unnecessarily.

Example command: beet lyrics -f --no-keep-synced -p "artist:Big Wreck" "title:If All Else Fails"
Relevant lrclib: https://lrclib.net/tracks/34472180

Before fix (plain lyrics only):

lyrics: LyricsPlugin: Fetching lyrics for Big Wreck - If All Else Fails
lyrics: LyricsPlugin: 🟢 Found lyrics: Big Wreck - 7.1 - If All Else Fails
...
Till it all blows up (It all blows up)
We're still in denial (We're still in denial)
How's it go if all else fails?
So far past denial (So far past the dial)
Where do we go if all else fails?

After fix (synced):

lyrics: LyricsPlugin: Fetching lyrics for Big Wreck - If All Else Fails
lyrics: LyricsPlugin: 🟢 Found lyrics: Big Wreck - 7.1 - If All Else Fails
...
[04:43.756] Till it all blows up (It all blows up)
[04:47.980] We're still in denial (We're still in denial)
[04:51.654] How's it go if all else fails?
[04:55.496] So far past denial (So far past the dial)
[04:59.170] Where do we go if all else fails?

@mlandry
mlandry force-pushed the fix/lyrics-millisecond-precision branch 2 times, most recently from 32c3f6b to 2aa3e1e Compare September 10, 2026 15:34
@snejus

snejus commented Sep 10, 2026

Copy link
Copy Markdown
Member

Ah makes sense!

Comment thread beets/util/lyrics.py Resolved
Comment thread docs/changelog.rst Resolved
LRCLIB commonly returns LRC timestamps with 3 decimal places ([mm:ss.xxx]).
LINE_PARTS_PAT and LRC_TIMESTAMP_PAT strictly expected two digits (\.\d\d),
causing verify_synced_lyrics to fail when the final line of a song has
millisecond precision (e.g. Final Light - Final Light ending with [06:07.301])
and fall back to plain text.

Additionally, interior 3-decimal lines had timestamps dropped from ID3 SYLT
frames and leaked raw bracketed tags into plain text extraction.

- Update regexes to accept \.\d{2,3}
- Parse both 2-digit (cs) and 3-digit (ms) fractions in Lyrics.sylt
- Add unit tests and changelog entry
@mlandry
mlandry force-pushed the fix/lyrics-millisecond-precision branch from 2aa3e1e to 6411f82 Compare September 11, 2026 02:35

@snejus snejus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@snejus
snejus merged commit 103390f into beetbox:master Sep 11, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lyrics lyrics plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants