feat: extract_text.py --fliesstext für lesbaren Fließtext

Umbruch auf 80 Zeichen ohne Worttrennung, auch nicht am Bindestrich.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Dieter Schlüter 2026-10-10 19:53:42 +02:00
commit 19b6bbf5a2

View file

@ -46,6 +46,22 @@ def test_default_language_is_original_audio(fake_yt_dlp, tmp_path, monkeypatch,
assert [p.name for p in tmp_path.iterdir()] == ["output.txt"]
def test_fliesstext(fake_yt_dlp, tmp_path, monkeypatch, capsys):
long_vtt = "WEBVTT\n\n" + "".join(
f"00:00:{i:02d}.000 --> 00:00:{i + 1:02d}.000\nSatz Nummer {i} zum EU-Gipfel.\n\n"
for i in range(20)
)
monkeypatch.setattr(yt.subprocess, "run", fake_yt_dlp(GERMAN_VIDEO, vtt=long_vtt))
target = tmp_path / "rede.txt"
run_main(monkeypatch, "-u", URL, "-f", "-o", target)
lines = target.read_text(encoding="utf-8").splitlines()
assert 1 < len(lines) < 20
assert all(len(line) <= extract_text.FLOW_WIDTH for line in lines)
assert " ".join(lines) == " ".join(f"Satz Nummer {i} zum EU-Gipfel." for i in range(20))
assert "100 Wörter" in capsys.readouterr().out
def test_explicit_language_prefers_manual(fake_yt_dlp, tmp_path, monkeypatch):
run = fake_yt_dlp(GERMAN_VIDEO, vtt=VTT)
monkeypatch.setattr(yt.subprocess, "run", run)