Ported from PR #50 (Themegaindex) onto current main, adapted to the billing-mode app.py and the Lumen dashboard: - subtitles.py: karaoke ASS generation (word-level highlight, glow/pop/box effects, dim/uppercase), whisper continuation-word merging, env-configurable whisper model, ASS/font input sanitization, faststart - editor.py + edit_builder.py: Auto-Edit v2 — Gemini returns a structured edit-decision list and the FFmpeg filter is built deterministically with hard caps (no raw filter strings from the LLM), 2s dry-run + one self-repair round, caption-safe mode blocks zooms on subtitled clips - app.py: /api/subtitle karaoke fields + re-subtitle prefix walk-back (fixes double subtitles), has_captions passed to Auto-Edit - hooks.py: emoji rendering (color-emoji font with strip fallback), char-level hard wrap, unique temp PNGs, ffmpeg timeouts; keeps the duration/enable overlay fromb1113d7- translate.py: exponential-backoff retries for transient ElevenLabs errors - dashboard: 11 caption presets in SubtitleModal; karaoke burns server-side - tests/: 50 pytest tests; .github/workflows/ci.yml runs them + fe build Encode settings kept at CRF 18 (medium for post-process steps) perf791a74. Co-authored-by: Themegaindex <themegaindex@users.noreply.github.com>
44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
"""Tests for hook overlay text handling (emoji runs, long-word wrapping)."""
|
|
from PIL import Image, ImageDraw, ImageFont
|
|
|
|
from hooks import _split_emoji_runs, _break_long_word, _EMOJI_RE
|
|
|
|
|
|
def _draw_and_font():
|
|
img = Image.new("RGBA", (1, 1))
|
|
draw = ImageDraw.Draw(img)
|
|
return draw, ImageFont.load_default()
|
|
|
|
|
|
class TestEmojiRuns:
|
|
def test_split_mixed_text(self):
|
|
assert _split_emoji_runs("Feuer 🔥 test") == [
|
|
(False, "Feuer "),
|
|
(True, "🔥"),
|
|
(False, " test"),
|
|
]
|
|
|
|
def test_plain_text_single_run(self):
|
|
assert _split_emoji_runs("nur text") == [(False, "nur text")]
|
|
|
|
def test_emoji_only(self):
|
|
assert _split_emoji_runs("🔥🚀") == [(True, "🔥🚀")]
|
|
|
|
def test_strip_regex(self):
|
|
assert _EMOJI_RE.sub("", "Stop 🛑 doing this! 💯") == "Stop doing this! "
|
|
|
|
|
|
class TestLongWordWrap:
|
|
def test_pieces_fit_and_recombine(self):
|
|
draw, font = _draw_and_font()
|
|
word = "A" * 60
|
|
max_width = 50
|
|
pieces = _break_long_word(draw, word, font, None, max_width)
|
|
assert len(pieces) > 1
|
|
assert "".join(pieces) == word
|
|
for piece in pieces:
|
|
assert draw.textlength(piece, font=font) <= max_width
|
|
|
|
def test_short_word_single_piece(self):
|
|
draw, font = _draw_and_font()
|
|
assert _break_long_word(draw, "kurz", font, None, 1000) == ["kurz"]
|