fix: yt-dlp im temporären Verzeichnis ausführen (Streudatei „3“)
yt-dlp ruft zur Prüfung „ffmpeg -bsfs“ auf; das System-ffmpeg 6.1.1 (Ubuntu) legt dabei eine leere Datei „3“ im Arbeitsverzeichnis an. yt-dlp läuft jetzt in einem temporären Verzeichnis mit absolutem Zielpfad, die Datei verschwindet mit dem Verzeichnis. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
60c7c10abb
commit
7e6ffa5899
1 changed files with 40 additions and 13 deletions
|
|
@ -1,6 +1,7 @@
|
|||
"""Tests for yt_untertitel.py; yt-dlp is always replaced by fakes (no network)."""
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
|
|
@ -67,6 +68,19 @@ def test_main_downloads_auto_original(fake_yt_dlp, tmp_path, monkeypatch, capsys
|
|||
assert "vtt2txt.py -i" in out
|
||||
|
||||
|
||||
def test_yt_dlp_runs_in_temporary_directory(fake_yt_dlp, tmp_path, monkeypatch):
|
||||
# ffmpeg -bsfs, called by yt-dlp, leaves a file "3" in its working directory
|
||||
run = fake_yt_dlp(AUTO_ONLY)
|
||||
monkeypatch.setattr(yt.subprocess, "run", run)
|
||||
monkeypatch.chdir(tmp_path)
|
||||
run_main(monkeypatch, "-u", URL, "-n", "Rede")
|
||||
|
||||
assert all(cwd is not None and Path(cwd) != tmp_path for cwd in run.cwds)
|
||||
template = run.calls[1][run.calls[1].index("-o") + 1]
|
||||
assert template == f"{tmp_path / 'Rede'}.%(ext)s"
|
||||
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):
|
||||
info = dict(AUTO_ONLY, subtitles={"de": []})
|
||||
run = fake_yt_dlp(info)
|
||||
|
|
@ -84,7 +98,7 @@ def test_main_no_matching_track(fake_yt_dlp, tmp_path, monkeypatch):
|
|||
|
||||
|
||||
def test_main_info_error(tmp_path, monkeypatch):
|
||||
def run(command, capture_output, text):
|
||||
def run(command, capture_output, text, cwd=None):
|
||||
return subprocess.CompletedProcess(command, 1, "", "ERROR: Video unavailable")
|
||||
|
||||
monkeypatch.setattr(yt.subprocess, "run", run)
|
||||
|
|
|
|||
Loading…
Reference in a new issue