refactor: Zeitauswahl nur noch über -z, -s/-e entfallen
-z 00:05:10 (ab), -z 0-00:20 (vom Anfang bis), -z 00:05-00:06 und mehrere Bereiche, mit oder ohne Anführungszeichen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
5e9a11d0f4
commit
8edef11c78
1 changed files with 93 additions and 108 deletions
|
|
@ -130,7 +130,7 @@ def test_cli_errors(tmp_path, monkeypatch, capsys, args, message):
|
|||
def test_time_range_default_name(fake_yt_dlp, tmp_path, monkeypatch):
|
||||
monkeypatch.setattr(yt.subprocess, "run", fake_yt_dlp(GERMAN_VIDEO, vtt=VTT))
|
||||
monkeypatch.chdir(tmp_path)
|
||||
run_main(monkeypatch, "-u", URL, "-s", "0:00:02", "-e", "0:00:03")
|
||||
run_main(monkeypatch, "-u", URL, "-z", "0:00:02-0:00:03")
|
||||
|
||||
name = "Kanal_Eine_Rede_2026-03-28_00-00-02_bis_00-00-03.txt"
|
||||
assert (tmp_path / name).read_text(encoding="utf-8") == (
|
||||
|
|
@ -141,14 +141,14 @@ def test_time_range_default_name(fake_yt_dlp, tmp_path, monkeypatch):
|
|||
def test_time_range_without_text(fake_yt_dlp, tmp_path, monkeypatch):
|
||||
monkeypatch.setattr(yt.subprocess, "run", fake_yt_dlp(GERMAN_VIDEO, vtt=VTT))
|
||||
with pytest.raises(SystemExit, match="im gewählten Zeitraum keinen Text"):
|
||||
run_main(monkeypatch, "-u", URL, "-s", "1:00", "-o", tmp_path / "out.txt")
|
||||
run_main(monkeypatch, "-u", URL, "-z", "1:00", "-o", tmp_path / "out.txt")
|
||||
|
||||
|
||||
def test_time_range_order_error(monkeypatch, capsys):
|
||||
with pytest.raises(SystemExit) as exc:
|
||||
run_main(monkeypatch, "-u", URL, "-s", "2:00", "-e", "1:00")
|
||||
run_main(monkeypatch, "-u", URL, "-z", "2:00-1:00")
|
||||
assert exc.value.code == 2
|
||||
assert "muss vor -e/--ende liegen" in capsys.readouterr().err
|
||||
assert "Start muss vor Ende" in capsys.readouterr().err
|
||||
|
||||
|
||||
CUT_VTT = (
|
||||
|
|
@ -165,7 +165,7 @@ CUT_VTT = (
|
|||
def test_time_range_sentence_bounds(fake_yt_dlp, tmp_path, monkeypatch, exact, text):
|
||||
monkeypatch.setattr(yt.subprocess, "run", fake_yt_dlp(GERMAN_VIDEO, vtt=CUT_VTT))
|
||||
target = tmp_path / "out.txt"
|
||||
run_main(monkeypatch, "-u", URL, "-s", "0:00:02", "-e", "0:00:03", "-o", target, *exact)
|
||||
run_main(monkeypatch, "-u", URL, "-z", "0:00:02-0:00:03", "-o", target, *exact)
|
||||
assert target.read_text(encoding="utf-8") == text
|
||||
|
||||
|
||||
|
|
@ -182,7 +182,7 @@ def test_several_ranges_flow_text_keeps_headers(fake_yt_dlp, tmp_path, monkeypat
|
|||
monkeypatch.chdir(tmp_path)
|
||||
run_main(monkeypatch, "-u", URL, "-z", "0:00:00-0:00:30 0:02", "-f")
|
||||
|
||||
name = "Kanal_Eine_Rede_2026-03-28_00-00-00_bis_00-00-30+ab_00-02-00.txt"
|
||||
name = "Kanal_Eine_Rede_2026-03-28_bis_00-00-30+ab_00-02-00.txt"
|
||||
assert (tmp_path / name).read_text(encoding="utf-8") == (
|
||||
"[00:00:01 - 00:00:02]\nErster Satz der\nRede.\n\n"
|
||||
"[00:02:00 - 00:02:01]\nDritter Satz, der\netwas länger ist.\n"
|
||||
|
|
|
|||
Loading…
Reference in a new issue