Skip to content
Merged
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
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
default = matebot;
matebot = pkgs.python3Packages.buildPythonApplication {
pname = "matebot";
version = "0.3.0";
version = "0.3.1";
pyproject = true;
src = self;
build-system = [ pkgs.python3Packages.hatchling ];
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "matebot"
version = "0.3.0"
version = "0.3.1"
description = "The proactive companion for GaggiMate espresso machines: post-shot logging bot, .slog decoder, shot-journal site generator"
readme = "README.md"
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion src/matebot/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""matebot — the proactive companion for GaggiMate espresso machines."""

__version__ = "0.3.0"
__version__ = "0.3.1"
12 changes: 12 additions & 0 deletions src/matebot/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,18 @@ async def _cmd_vsync(self) -> None:
f"🎬 Shot #{shot} video offset: {current:+.2f}s → {current + delta:+.2f}s. "
"Journal updates on the next sync."
)
try:
from .render import RenderError, render_reel

reel = await render_reel(self.config.data_repo, shot, title=f"Shot #{shot}")
try:
await self.messenger.send_video(
reel.read_bytes(), f"🎬 Shot #{shot} @ {current + delta:+.2f}s"
)
finally:
reel.unlink(missing_ok=True)
except RenderError as exc:
log.info("no reel re-render for shot %06d: %s", shot, exc)

async def _cmd_digest(self) -> None:
text = await build_digest(self.client, self.config)
Expand Down
3 changes: 1 addition & 2 deletions src/matebot/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
WIDTH = 720
CHART_H = 406
PLAYHEAD = "0xF0561D" # GaggiMate orange
TAIL_S = 2.0


class RenderError(Exception):
Expand Down Expand Up @@ -61,7 +60,7 @@ async def render_reel(repo: str | Path, shot_id: int, *, title: str | None = Non
delay = max(0.0, -offset) # video starts this long after chart t=0
trim = max(0.0, offset) # positive offset: drop the clip's head instead
dur = geom["t_end"] # animate across the actual data range
total = dur + TAIL_S
total = dur # end exactly when the playhead reaches the end of the x axis

# scale axis geometry from the rendered PNG to the reel's chart panel
sx, sy = WIDTH / geom["img_w"], CHART_H / geom["img_h"]
Expand Down
1 change: 1 addition & 0 deletions tests/test_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def test_positive_offset_trims_clip(repo, monkeypatch):
out = asyncio.run(render.render_reel(repo, 4))
args = calls[0]
assert args[args.index("-ss") + 1] == "0.60"
assert args[args.index("-t") + 1] == f"{GEOM['t_end']:.2f}" # ends at the x-axis end
assert "adelay=0|0" in args[args.index("-filter_complex") + 1]
assert out.read_bytes() == b"reel"
out.unlink()
Expand Down
Loading