diff --git a/beetsplug/lyrics.py b/beetsplug/lyrics.py index 0e7c986cb8..57c45ac311 100644 --- a/beetsplug/lyrics.py +++ b/beetsplug/lyrics.py @@ -1101,7 +1101,14 @@ def commands(self): "--keep-synced", action="store_true", default=self.config["keep_synced"].get(), - help="re-download only unsynced lyrics", + help="skip items that already have synced lyrics", + ) + cmd.parser.add_option( + "--no-keep-synced", + action="store_false", + dest="keep_synced", + default=self.config["keep_synced"].get(), + help="do not skip items that already have synced lyrics", ) cmd.parser.add_option( "-l", diff --git a/docs/changelog.rst b/docs/changelog.rst index 2609ce8fa9..1f19abe0df 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -21,6 +21,8 @@ New features - A database backup is now automatically created before running schema migrations. Control with the ``create_backup_before_migrations`` option (default: yes). +- :doc:`plugins/lyrics`: Added a ``--no-keep-synced`` command option to override + ``keep_synced: yes`` for a single manual lyrics fetch. Bug fixes ~~~~~~~~~ diff --git a/docs/plugins/lyrics.rst b/docs/plugins/lyrics.rst index 8fa2b4c1db..0daa3af000 100644 --- a/docs/plugins/lyrics.rst +++ b/docs/plugins/lyrics.rst @@ -145,7 +145,9 @@ that already have lyrics. The ``--keep-synced`` option skips tracks that already have synced lyrics, regardless of the ``force`` flag. This is handy when you want to re-fetch plain -lyrics without touching tracks that already have a synced version. +lyrics without touching tracks that already have a synced version. Use +``--no-keep-synced`` to override a ``keep_synced: yes`` configuration for a +single command run. Inversely, the ``-l, --local`` option restricts operations to lyrics that are locally available, which show lyrics faster without using the network at all. diff --git a/test/plugins/test_lyrics.py b/test/plugins/test_lyrics.py index 1251043774..65ccca0c01 100644 --- a/test/plugins/test_lyrics.py +++ b/test/plugins/test_lyrics.py @@ -885,6 +885,39 @@ def write(self, items): assert test_capture.get("directory") == Path(output_path).expanduser() +class TestLyricsKeepSyncedCommand(PluginTestHelper): + plugin = "lyrics" + + @pytest.mark.parametrize( + "config_keep_synced, cmd_args, expected_keep_synced", + [ + pytest.param(False, (), False, id="disabled-by-default"), + pytest.param(True, (), True, id="enabled-by-config"), + pytest.param(False, ("--keep-synced",), True, id="cli-enables"), + pytest.param( + True, ("--no-keep-synced",), False, id="cli-disables-config" + ), + ], + ) + def test_keep_synced_cli_option( + self, monkeypatch, config_keep_synced, cmd_args, expected_keep_synced + ): + self.config["lyrics"]["keep_synced"] = config_keep_synced + self.add_item(lyrics="[00:00.00] old synced") + observed_keep_synced = [] + + def capture_keep_synced(plugin, *_): + observed_keep_synced.append(plugin.config["keep_synced"].get(bool)) + + monkeypatch.setattr( + lyrics.LyricsPlugin, "add_item_lyrics", capture_keep_synced + ) + + self.run_command("lyrics", *cmd_args) + + assert observed_keep_synced.pop(0) is expected_keep_synced + + class TestLyricsSyltProperty: """Unit tests for the Lyrics.sylt timestamp-to-millisecond converter."""