Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion beetsplug/lyrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
Comment thread
Copilot marked this conversation as resolved.
cmd.parser.add_option(
"-l",
Expand Down
2 changes: 2 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
~~~~~~~~~
Expand Down
4 changes: 3 additions & 1 deletion docs/plugins/lyrics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
33 changes: 33 additions & 0 deletions test/plugins/test_lyrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down
Loading