Compare commits

...

2 Commits

5 changed files with 23 additions and 6 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project] [project]
name = "lrx-cli" name = "lrx-cli"
version = "0.7.1" version = "0.7.2"
description = "Fetch line-synced lyrics for your music player." description = "Fetch line-synced lyrics for your music player."
readme = "README.md" readme = "README.md"
requires-python = ">=3.13" requires-python = ">=3.13"
+13 -3
View File
@@ -390,24 +390,34 @@ def pipe(
before: Annotated[ before: Annotated[
int, int,
cyclopts.Parameter( cyclopts.Parameter(
name="--before", name=["--before", "-b"],
help="Number of lyric lines to show before current line.", help="Number of lyric lines to show before current line.",
), ),
] = 0, ] = 0,
after: Annotated[ after: Annotated[
int, int,
cyclopts.Parameter( cyclopts.Parameter(
name="--after", name=["--after", "-a"],
help="Number of lyric lines to show after current line.", help="Number of lyric lines to show after current line.",
), ),
] = 0, ] = 0,
no_newline: Annotated[
bool,
cyclopts.Parameter(
name=["--no-newline", "-n"],
negative="",
help="Do not append a new line after the lyric output.",
),
] = False,
): ):
"""Watch active player and continuously print lyric window to stdout.""" """Watch active player and continuously print lyric window to stdout."""
logger.info( logger.info(
"Starting watch pipe (player filter: {})", "Starting watch pipe (player filter: {})",
_player or "<none>", _player or "<none>",
) )
output = PipeOutput(before=max(0, before), after=max(0, after)) output = PipeOutput(
before=max(0, before), after=max(0, after), no_newline=no_newline
)
try: try:
session = WatchCoordinator( session = WatchCoordinator(
manager, manager,
+6
View File
@@ -292,6 +292,12 @@ class WatchCoordinator:
started_fetch = False started_fetch = False
if track is not None and (player_changed or track_changed): if track is not None and (player_changed or track_changed):
started_fetch = self._request_fetch_for_active_track("track-changed") started_fetch = self._request_fetch_for_active_track("track-changed")
elif (
track is not None
and self._model.lyrics is None
and self._model.status == "paused"
):
started_fetch = self._request_fetch_for_active_track("resume-playing")
if self._model.lyrics is not None: if self._model.lyrics is not None:
self._model.status = "ok" self._model.status = "ok"
+2 -1
View File
@@ -13,6 +13,7 @@ class PipeOutput(BaseOutput):
before: int = 0 before: int = 0
after: int = 0 after: int = 0
no_newline: bool = False
def _window_size(self) -> int: def _window_size(self) -> int:
"""Return rendered lyric window size.""" """Return rendered lyric window size."""
@@ -81,5 +82,5 @@ class PipeOutput(BaseOutput):
lines = self._render_lyrics(state) lines = self._render_lyrics(state)
for line in lines: for line in lines:
print(line) sys.stdout.write(line + ("\n" if not self.no_newline else ""))
sys.stdout.flush() sys.stdout.flush()
Generated
+1 -1
View File
@@ -153,7 +153,7 @@ wheels = [
[[package]] [[package]]
name = "lrx-cli" name = "lrx-cli"
version = "0.7.1" version = "0.7.2"
source = { editable = "." } source = { editable = "." }
dependencies = [ dependencies = [
{ name = "cyclopts" }, { name = "cyclopts" },