feat: Standard-Dateiname aus Kanal, Titel und Datum des Videos

- yt_untertitel.default_name(): <Kanal>_<Titel>_<Datum>, z. B.
  John_Mearsheimer_Offensive_Realism_Episode_1_Origins_of_the_War_In_Ukraine_2026-07-30
- Bindestriche/Punkte im Wort bleiben, Kanal max. 40, Titel max. 60 Zeichen
  an Wortgrenze; ohne Kanal und Titel die Video-ID
- Gilt ohne -o/-n in extract_text.py (statt output.txt), yt_untertitel.py
  und rede_korrigieren.py -u (statt Video-ID)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Dieter Schlüter 2026-10-10 21:03:14 +02:00
commit 3d9a5037c2

View file

@ -12,6 +12,8 @@ URL = "https://www.youtube.com/watch?v=abc123"
AUTO_ONLY = {
"id": "abc123",
"title": "Eine Rede",
"channel": "Kanal",
"upload_date": "20260328",
"subtitles": {},
"automatic_captions": {"de-orig": [], "de": [], "en": []},
}
@ -86,6 +88,24 @@ def test_original_language_with_dubbed_audio(info, expected):
assert yt.original_language(info) == expected
@pytest.mark.parametrize("info, expected", [
({"channel": "John Mearsheimer - Offensive Realism",
"title": "Episode 1: Origins of the War In Ukraine", "upload_date": "20260730"},
"John_Mearsheimer_Offensive_Realism_Episode_1_Origins_of_the_War_In_Ukraine_2026-07-30"),
# Title cut at a word boundary after 60 characters; hyphens and dots in words stay
({"channel": "GGBLahnstein", "upload_date": "20260730",
"title": "Prof. Gabriele Krone-Schmalz – Respekt geht anders – "
"GGB-Gesundheitstage, Lahnstein 28.03.2026"},
"GGBLahnstein_Prof_Gabriele_Krone-Schmalz_Respekt_geht_anders_2026-07-30"),
({"uploader": "Ein Kanal", "title": "A/B: Krieg & Frieden 🎤?"}, "Ein_Kanal_A_B_Krieg_Frieden"),
({"title": "Nur Titel", "upload_date": "kaputt"}, "Nur_Titel"),
({"id": "abc123", "title": "🎤 – …"}, "abc123"),
({"title": "x" * 80}, "x" * 60),
])
def test_default_name(info, expected):
assert yt.default_name(info) == expected
def test_available_tracks_hides_dubs():
assert yt.available_tracks(DUBBED) == (["en-US"], ["en"])
@ -124,13 +144,13 @@ def test_yt_dlp_runs_in_temporary_directory(fake_yt_dlp, tmp_path, monkeypatch):
assert (tmp_path / "Rede.de-orig.vtt").is_file()
def test_main_prefers_manual_and_defaults_to_video_id(fake_yt_dlp, tmp_path, monkeypatch):
def test_main_prefers_manual_and_default_name(fake_yt_dlp, tmp_path, monkeypatch):
info = dict(AUTO_ONLY, subtitles={"de": []})
run = fake_yt_dlp(info)
monkeypatch.setattr(yt.subprocess, "run", run)
run_main(monkeypatch, "-u", URL, "-d", tmp_path)
assert (tmp_path / "abc123.de.vtt").is_file()
assert (tmp_path / "Kanal_Eine_Rede_2026-03-28.de.vtt").is_file()
assert "--write-subs" in run.calls[1]