mirror of
https://github.com/beetbox/beets.git
synced 2025-12-15 13:07:09 +01:00
lyrics: Fallback to plain lyrics if synced lyrics not available (#5089)
The `synced` config flag was not working the way the docs described it for the LRCLIB source. With `synced: yes`, if a track does not have synced lyrics, but does have plain lyrics, the plugin would return no lyrics. The docs imply that, with the flag enabled, it would still use plain lyrics if there are no synced lyrics. LRCLIB API call that returns plain lyrics can be found [here](https://lrclib.net/api/get?artist_name=Hania%20Rani&track_name=Moans&album_name=Ghosts&duration=274).
This commit is contained in:
commit
af41eef776
3 changed files with 20 additions and 1 deletions
|
|
@ -277,7 +277,7 @@ class LRCLib(Backend):
|
|||
return None
|
||||
|
||||
if self.config["synced"]:
|
||||
return data.get("syncedLyrics")
|
||||
return data.get("syncedLyrics") or data.get("plainLyrics")
|
||||
|
||||
return data.get("plainLyrics")
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,10 @@ Unreleased
|
|||
|
||||
New features:
|
||||
Bug fixes:
|
||||
|
||||
* :doc:`plugins/lyrics`: LRCLib will fallback to plain lyrics if synced lyrics
|
||||
are not found and `synced` flag is set to `yes`.
|
||||
|
||||
For packagers:
|
||||
Other changes:
|
||||
|
||||
|
|
|
|||
|
|
@ -620,6 +620,7 @@ class LRCLibLyricsTest(unittest.TestCase):
|
|||
mock_get.return_value.json.return_value = mock_response
|
||||
mock_get.return_value.status_code = 200
|
||||
|
||||
self.plugin.config["synced"] = False
|
||||
lyrics = lrclib.fetch("la", "la", "la", 999)
|
||||
assert lyrics == mock_response["plainLyrics"]
|
||||
|
||||
|
|
@ -627,6 +628,19 @@ class LRCLibLyricsTest(unittest.TestCase):
|
|||
lyrics = lrclib.fetch("la", "la", "la", 999)
|
||||
assert lyrics == mock_response["syncedLyrics"]
|
||||
|
||||
@patch("beetsplug.lyrics.requests.get")
|
||||
def test_fetch_synced_lyrics_fallback(self, mock_get):
|
||||
mock_response = {
|
||||
"syncedLyrics": "",
|
||||
"plainLyrics": "la la la",
|
||||
}
|
||||
mock_get.return_value.json.return_value = mock_response
|
||||
mock_get.return_value.status_code = 200
|
||||
|
||||
self.plugin.config["synced"] = True
|
||||
lyrics = lrclib.fetch("la", "la", "la", 999)
|
||||
assert lyrics == mock_response["plainLyrics"]
|
||||
|
||||
@patch("beetsplug.lyrics.requests.get")
|
||||
def test_fetch_plain_lyrics(self, mock_get):
|
||||
mock_response = {
|
||||
|
|
@ -636,6 +650,7 @@ class LRCLibLyricsTest(unittest.TestCase):
|
|||
mock_get.return_value.json.return_value = mock_response
|
||||
mock_get.return_value.status_code = 200
|
||||
|
||||
self.plugin.config["synced"] = False
|
||||
lyrics = lrclib.fetch("la", "la", "la", 999)
|
||||
|
||||
assert lyrics == mock_response["plainLyrics"]
|
||||
|
|
|
|||
Loading…
Reference in a new issue