diff options
author | jeff <jeff@moo.dev> | 2023-11-05 10:59:30 -0500 |
---|---|---|
committer | jeff <jeff@moo.dev> | 2023-11-05 11:26:33 -0500 |
commit | 7b0f5fb3f34953c690197b0e7991b0b6325234dd (patch) | |
tree | b0f14ae09cfd68847fe0885c46fd6e5ee4dde301 | |
parent | e14982cad78a9ac9e91dda48fa45989b034c17db (diff) |
Add config option to prefer synced lyrics over plain
-rw-r--r-- | beetsplug/lyrics.py | 6 | ||||
-rw-r--r-- | docs/changelog.rst | 3 | ||||
-rw-r--r-- | docs/plugins/lyrics.rst | 1 | ||||
-rw-r--r-- | test/plugins/test_lyrics.py | 3 |
4 files changed, 11 insertions, 2 deletions
diff --git a/beetsplug/lyrics.py b/beetsplug/lyrics.py index 5c8ba3543..a88a55791 100644 --- a/beetsplug/lyrics.py +++ b/beetsplug/lyrics.py @@ -312,7 +312,10 @@ class LRCLib(Backend): self._log.debug("LRCLib API request failed: {0}", exc) return None - return data.get("syncedLyrics") or data.get("plainLyrics") + if self.config["synced"]: + return data.get("syncedLyrics") + + return data.get("plainLyrics") class MusiXmatch(Backend): @@ -796,6 +799,7 @@ class LyricsPlugin(plugins.BeetsPlugin): "fallback": None, "force": False, "local": False, + "synced": False, # Musixmatch is disabled by default as they are currently blocking # requests with the beets user agent. "sources": [s for s in self.SOURCES if s != "musixmatch"], diff --git a/docs/changelog.rst b/docs/changelog.rst index 9f51921eb..728605d81 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -141,7 +141,8 @@ New features: but no thumbnail is provided by CAA. We now fallback to the raw image. * :doc:`/plugins/advancedrewrite`: Add an advanced version of the `rewrite` plugin which allows to replace fields based on a given library query. -* :doc:`/plugins/lyrics`: Add LRCLIB as a new lyrics provider. +* :doc:`/plugins/lyrics`: Add LRCLIB as a new lyrics provider and a new + `synced` option to prefer synced lyrics over plain lyrics. Bug fixes: diff --git a/docs/plugins/lyrics.rst b/docs/plugins/lyrics.rst index 68ab86301..8a9abdb46 100644 --- a/docs/plugins/lyrics.rst +++ b/docs/plugins/lyrics.rst @@ -64,6 +64,7 @@ configuration file. The available options are: is setup. The ``google``, ``genius``, and ``tekstowo`` sources will only be enabled if BeautifulSoup is installed. +- **synced**: Prefer synced lyrics over plain lyrics if a source offers them. Currently `lrclib` is the only source that provides them. Default: `no`. Here's an example of ``config.yaml``:: diff --git a/test/plugins/test_lyrics.py b/test/plugins/test_lyrics.py index 508400146..4bfeda80e 100644 --- a/test/plugins/test_lyrics.py +++ b/test/plugins/test_lyrics.py @@ -697,7 +697,10 @@ class LRCLibLyricsTest(unittest.TestCase): mock_get.return_value.status_code = 200 lyrics = lrclib.fetch("la", "la", "la", 999) + self.assertEqual(lyrics, mock_response["plainLyrics"]) + self.plugin.config["synced"] = True + lyrics = lrclib.fetch("la", "la", "la", 999) self.assertEqual(lyrics, mock_response["syncedLyrics"]) @patch("beetsplug.lyrics.requests.get") |