Commit Graph

380 Commits

Author SHA1 Message Date
kelamg
47148d5100 Fix formatting 2026-03-22 01:46:50 +00:00
kelamg
7556beb33a Revert docstring 2026-03-22 01:46:50 +00:00
kelamg
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
kelamg
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
Šarūnas Nejus
1c20e4bd4e Address RUF012 2026-01-13 20:55:40 +00:00
Šarūnas Nejus
72f7d6ebe3 Refactor HTTP request handling with RequestHandler base class
Introduce a new RequestHandler base class to introduce a shared session,
centralize HTTP request management and error handling across plugins.

Key changes:
- Add RequestHandler base class with a shared/cached session
- Convert TimeoutSession to use SingletonMeta for proper resource
  management
- Create LyricsRequestHandler subclass with lyrics-specific error
  handling
- Update MusicBrainzAPI to inherit from RequestHandler
2025-12-21 00:40:40 +00:00
Šarūnas Nejus
2a63e13617 musicbrainz: lookup release directly 2025-12-20 01:35:51 +00:00
Šarūnas Nejus
fda3bbaea5 Move TimeoutSession under beetsplug._utils 2025-12-20 01:35:51 +00:00
Šarūnas Nejus
d486885af3 pyupgrade Python 3.10 2025-11-08 12:09:52 +00:00
Ratiq Narwal
e9afe069bc Accept lyrics source as a string 2025-11-06 17:19:27 -08:00
Šarūnas Nejus
ec141dbfd6 Explicitly wrap partial with staticmethod for Py3.14 2025-10-27 08:23:37 +00:00
Sebastian Mohr
b2fc007480 Fixed plugin typehints: use actual logger class. 2025-09-30 13:37:51 +02:00
Šarūnas Nejus
44fda7ca0a lyrics: use another beatles song for Lyricsmode
Lady Madonna apparently is gone from this website. ¯\_(ツ)_/¯
2025-08-30 23:10:22 +01:00
Šarūnas Nejus
b3d434f58f Delegate attribute access to logging 2025-08-30 23:10:21 +01:00
Šarūnas Nejus
d93ddf8dd4 Do not use explicit indices for logging args when not needed 2025-08-30 23:10:21 +01:00
Šarūnas Nejus
1c16b2b308 Replace string concatenation (' + ')
- Join hardcoded strings
- Replace concatenated variables with f-strings
2025-08-30 23:10:15 +01:00
Šarūnas Nejus
4a361bd501 Replace format calls with f-strings 2025-08-30 18:42:26 +01:00
Šarūnas Nejus
adbd50b237 Move distance to a separate module 2025-05-31 19:17:43 +01:00
Šarūnas Nejus
509cbdcbe4 Move sanitize_pairs/choices from plugins to util module 2025-05-31 17:55:41 +01:00
Šarūnas Nejus
c490ac5810 Fix formatting 2025-05-07 10:41:01 +01:00
Šarūnas Nejus
b713d72612 translations: use a more distinctive separator
I found that the translator would sometimes replace the pipe character
with another symbol (maybe it got confused thinking the character is
part of the text?).

Added spaces around the pipe to make it more clear that it's definitely
the separator.
2025-02-20 03:47:04 +00:00
Šarūnas Nejus
43032f7bc7 translations: make sure we do not re-translate 2025-02-20 03:47:04 +00:00
Šarūnas Nejus
7893766e4c Improve flags structure and add tests 2025-02-20 03:47:04 +00:00
Šarūnas Nejus
c95156adcd Refactor writing rest files 2025-02-20 03:47:04 +00:00
Šarūnas Nejus
d7201062a8 Resurrect translation functionality 2025-02-20 03:47:04 +00:00
Šarūnas Nejus
dab9a0d7c4 Bring back Tekstowo search
It was my mistake to remove search earlier - I found that in many cases
it works fine.
2025-01-27 10:56:54 +00:00
Šarūnas Nejus
7389f241f4 Do not search for Various Artists, split titles by ' / ' 2025-01-27 10:56:53 +00:00
Šarūnas Nejus
39c479fcab Google: add support for dainuzodziai.lt 2025-01-27 10:56:53 +00:00
Šarūnas Nejus
734bcc28a8 Append source to the lyrics 2025-01-27 10:56:53 +00:00
Šarūnas Nejus
bdc564a573 Tidy up handling of backends 2025-01-27 10:56:53 +00:00
Šarūnas Nejus
04054cac5c Remove dependency existence checks
I think we can make our life easier by removing these checks assuming
that users follow the instructions in the docs.
2025-01-27 10:56:53 +00:00
Šarūnas Nejus
b2402b1634 Google: make sure we do not return the captcha text
If we get caught by Cloudfare, it forwards our request somewhere else
and returns some validation text response. To make sure that this text
does not get assumed for lyrics, we can disable redirects for the Google
backend, check the response code and raise if there's a redirect
attempt. This source will then be skipped and the backend continues with
the next one.
2025-01-27 10:56:53 +00:00
Šarūnas Nejus
07d372c13d Google: prioritise Songlyrics and AZlyrics sources 2025-01-27 10:56:53 +00:00
Šarūnas Nejus
70554640e5 Create Html class for cleaning up the html text
Additionally, improve HTML pre-processing:

* Ensure a new line between blocks of lyrics text from letras.mus.br.
* Parse a missing last block of lyrics text from lacocinelle.net.
* Parse a missing last block of lyrics text from paroles.net.
* Fix encoding issues with AZLyrics by setting response encoding to
  None, allowing `requests` to handle it.
2025-01-27 10:56:52 +00:00