Commit Graph
410 Commits
Author SHA1 Message Date
Šarūnas Nejus 11d41aee7d typing: add missing types to plugins 2026-08-31 11:27:12 +01:00
Šarūnas Nejus d9e2b65758 Merge branch 'master' into fix/lrclib-null-lyrics 2026-08-22 17:41:55 +01:00
Šarūnas Nejus 6241139600 typing: define explicit optparse.Values for each command 2026-08-19 23:57:05 +01:00
Šarūnas Nejus 14eabc6060 typing: add types to command handlers 2026-08-19 23:57:01 +01:00
David HowardandClaude Opus 5 f68aefa058 lyrics: address review feedback
Return an empty string rather than INSTRUMENTAL_LYRICS from the final
fallback in LRCLyrics.get_text. That branch is not about an instrumental
track, so the marker was misleading.

Strip the LRC timestamps when synced lyrics stand in for a null
plainLyrics. The value is being used as plain text there, so the
timestamps do not belong in it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-15 17:52:56 -07:00
David Howard cd50a42c04 lyrics: don't match LRCLib entries that have no lyrics
LRCLib stores track metadata independently of the lyrics themselves, so an
entry can come back with both `plainLyrics` and `syncedLyrics` null while
`instrumental` is False. `LRCLyrics.is_valid` accepted such an entry as a
match on duration alone, and `get_text` then returned `self.plain`, i.e.
None, despite being annotated `-> str`.

The None propagated into `Lyrics`, and the first access of its text raised

    AttributeError: 'NoneType' object has no attribute 'splitlines'

`beet lyrics` surfaced this per track, but during an import the exception
escaped the pipeline stage and aborted the entire run: one such track
stranded every file queued behind it.

Treat an entry with no lyrics text as not a match, so the search moves on to
other candidates and backends and ultimately reports that no lyrics were
found. That is deliberately distinct from an instrumental track, where "no
lyrics" is itself the answer and the existing `instrumental` handling still
applies. Marking these as instrumental would assert something the API
response does not tell us.

Also fall back to synced lyrics when only `plainLyrics` is null, rather than
discarding lyrics we do have, and correct the annotations: `plainLyrics` and
`LRCLyrics.plain` are both nullable.
2026-08-15 17:49:54 -07:00
f1nn 0d65a46bbc lyrics: add lrcmux backend 2026-07-15 16:12:21 +02:00
Šarūnas Nejus d9a1bde1c9 Add --no-keep-synced CLI option to lyrics
- Allow manual lyrics fetches to override keep_synced configuration for a single
  run.
2026-07-13 01:14:41 +01:00
Šarūnas Nejus 8020c07acf Track instrumental lyrics metadata
- Leave lyrics text empty when a backend reports an instrumental track and
  persist that state in lyrics_instrumental.
2026-07-13 01:07:59 +01:00
Sebastian Mohr 54a2bd20e1 Removed This file is part of beets... headers. 2026-06-29 11:20:15 +02:00
Blake Hakkila 478ac8cb63 lyrics: add rest_directory configuration option 2026-06-15 22:48:00 -07:00
Alok Saboo 68ed8924ef TimeoutAndRetrySession: fold in RateLimitAdapter and 429 retry 2026-06-12 09:43:23 -04:00
Alok Saboo 9da0c4264f fix create_session return type annotation to match parent class 2026-06-11 08:48:24 -04:00
Alok Saboo 91ab049a22 refactor LyricsSession to extend TimeoutAndRetrySession
Simplifies by inheriting User-Agent, timeout, and raise_for_status
from the shared session base class, as suggested in review.
2026-06-11 08:15:53 -04:00
Alok Saboo 740597213f fix mypy return type and address copilot review comments
- Change RequestHandler.create_session()/session return type to
  requests.Session so subclasses can override with custom session types
- Use setdefault for User-Agent header to respect custom overrides
- Clarify rate_limit parameter units in docstring
2026-06-10 21:33:54 -04:00
Alok Saboo 49c415a302 lyrics: add rate limiting and exponential backoff to prevent 429 errors
Add a LyricsSession class that mounts RateLimitAdapter (4 req/sec)
and configures urllib3 Retry with exponential backoff on 429
responses. Each backend instance gets its own session so rate
limits apply independently per API source.

Fixes #6728
2026-06-10 21:24:31 -04:00
Šarūnas Nejus 648f24cbc2 Enable and fix flake8-builtins 2026-06-09 00:14:06 +01:00
Šarūnas Nejus fb9de7a619 lyrics: fix musica parsing 2026-06-03 15:42:19 +01:00
Šarūnas Nejus 5a22b40735 lyrics: introduce apply_methods 2026-06-02 15:46:43 +01:00
Šarūnas Nejus 29580d2f00 Import everything from parent beets.autotag 2026-06-02 08:57:35 +01:00
Benjamin Stevenson fc8217f576 merge: resolve changelog and poetry.lock conflicts with master 2026-05-21 19:50:06 -04:00
Benjamin Stevenson 85d5509baa fix: keep LRC in USLT, simplify synced_lyrics write path, fix poetry.lock 2026-05-21 19:48:37 -04:00
Sebastian Mohr adfb73b66d Run ruff format 2026-05-20 16:53:06 +02:00
Eyüp Can Akman 88be3023bb lyrics: handle apostrophes in musixmatch slug
The musixmatch URL slug builder did not replace curly apostrophes
(U+2018, U+2019) before applying the whitespace-to-dash rule, so titles
like "If They're Shooting at You" produced a slug with the raw quote
preserved and the lookup failed.

Add a REPLACEMENTS entry that maps both curly quote codepoints to a
dash before the rest of the substitutions run.
2026-04-28 17:27:28 +03:00
Benjamin Stevenson c9b1baee24 fix: keep LRC in DB, pass plain text to USLT via tags, bump mediafile to 0.17.0 2026-04-24 16:41:37 -04:00
Benjamin Stevenson edb1934fc9 fix: ruff formatting and lint errors 2026-04-22 18:14:31 -04:00
Benjamin Stevenson 78d9f89dbd Use mediafile synced_lyrics field instead of _write_sylt_to_id3 2026-04-22 18:11:01 -04:00
Benjamin Stevenson 26759b9c6e Address review: use XXX lang code, log save errors 2026-04-22 13:58:10 -04:00
Benjamin Stevenson fc769e9a79 lyrics: write synced LRC lyrics to SYLT ID3 frame
When the lyrics plugin writes LRC-formatted (timestamped) lyrics to an
ID3-tagged audio file, store the timing data in the SYLT (synchronized
lyrics) frame and plain text in USLT, rather than writing raw LRC text
verbatim to USLT.

Fixes #6541
2026-04-21 17:22:15 -04:00
Šarūnas Nejus 163b94d464 lyrics: add keep_synced option to not overwrite synced lyrics 2026-04-17 09:19:15 +01:00
kelamg 47148d5100 Fix formatting 2026-03-22 01:46:50 +00:00
kelamg 7556beb33a Revert docstring 2026-03-22 01:46:50 +00:00
kelamgandŠarūnas Nejus 131930144b Update beetsplug/lyrics.py
Co-authored-by: Šarūnas Nejus <snejus@protonmail.com>
2026-03-22 01:46:50 +00:00
kelamg b3bcb78349 Fix indentation 2026-03-22 01:46:50 +00:00
jochem 55b6fbe77d copied more generic implementation from snejus, and updated the tests and docs accordingly 2026-03-22 01:46:50 +00:00
kelamgandCopilot d4dc46591d Update beetsplug/lyrics.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-22 01:46:50 +00:00
kelamg 9a735df125 Fix formatting 2026-03-22 01:46:50 +00:00
jochem 2f9ee89b2a Added feature to exclude albums/songs during importing when auto is enabled, as requested in issue #3523. Also added corresponding tests and documentation. 2026-03-22 01:46:50 +00:00
Šarūnas Nejus ace6a99d07 Document methods changed/introduced 2026-03-06 10:57:08 +00:00
Šarūnas Nejus 05a822dd5c Move Lyrics class under beets.util as it is used by migrations 2026-03-06 10:57:08 +00:00
Šarūnas Nejus 50a564e66d Set constant langdetection seed for stable results 2026-03-06 10:57:08 +00:00
Šarūnas Nejus 7d30efa82c Migrate lyrics metadata to flex fields on library open
- Add `LyricsMetadataInFlexFieldsMigration` to extract legacy source
  URLs and language metadata from lyrics text into flex attributes
- Add `Lyrics.from_legacy_text` to parse legacy lyrics format
- Move `with_row_factory` context manager up to base `Migration` class
- Rename `migrate_table` to `migrate_model` and pass model class
  instead of table name string. This is so that the migration can access
  both `_table` and `_flex_table` attributes.
- Make `langdetect` import optional in `Lyrics.__post_init__`: users may
  not have have the dependency installed, and we do not want the
  migration to fail because of that.
- Move `BACKEND_BY_NAME` to module level for use outside plugin class
2026-03-06 10:57:08 +00:00
Šarūnas Nejus 7df14e1877 Fix timestamp format in translation/synced lyrics test 2026-03-06 10:57:08 +00:00
Šarūnas Nejus 38708ae592 Refactor lyrics handling to use structured Lyrics object
* Introduce a `Lyrics` dataclass to carry text, source URL, and language
  metadata through fetch, translation, and storage paths.
* Return `Lyrics` from backends and plugin lookup methods instead of raw
  tuples/strings.
* Store backend name in `lyrics_source` derived from fetched URL root
  domain.
* Simplify translator flow to operate on `Lyrics`, reuse line splitting,
  append translations in-place, and record translation language
  metadata.
2026-03-06 10:57:08 +00:00
Šarūnas Nejus 835115a6f7 Fix genius end to end lyrics test 2026-03-06 10:57:08 +00:00
Šarūnas Nejus c239275193 Do not split orig/trans if they are not different 2026-03-05 15:36:59 +00:00
Šarūnas Nejus 82bfc03494 Preserve synced lyrics when fetched result is plain text
When lyrics.synced is enabled, avoid replacing existing synced lyrics with
newly fetched unsynced lyrics, even with force enabled.

Allow replacement when the new lyrics are also synced, or when synced mode
is disabled.
2026-03-05 15:36:59 +00:00
Šarūnas Nejus 24ca6abcfe lyrics: validate synced lyrics duration 2026-03-05 15:34:32 +00:00
Šarūnas Nejus 37e18fbb46 Adapt code to fully typed confuse library 2026-02-16 12:45:05 +00:00
Kirill A. Korinsky 1d8c378e9f Disable Tekstowo by default as they block requests with the beets UA 2026-02-03 02:18:59 +01:00