split download and ffmpeg procces

This commit is contained in:
root
2026-09-27 12:52:05 +08:00
parent 993fd8f217
commit b6160430a0
13 changed files with 868 additions and 341 deletions
+25
View File
@@ -1,5 +1,6 @@
from __future__ import annotations
import shutil
from pathlib import Path
import pytest
@@ -76,6 +77,30 @@ def test_api_download_url_is_one_call_convenience(tmp_path: Path) -> None:
assert result.files[0].path.read_bytes() == b"one"
def test_api_downloads_segments_without_merging_or_ffmpeg(tmp_path: Path) -> None:
(tmp_path / "one.ts").write_bytes(b"one")
(tmp_path / "two.ts").write_bytes(b"two")
manifest = tmp_path / "movie.m3u8"
manifest.write_text("#EXTM3U\n#EXTINF:1,\none.ts\n#EXTINF:1,\ntwo.ts\n#EXT-X-ENDLIST\n")
result = N_m3u8DL().download_segments_url(
manifest,
DownloadRequest(
output_dir=tmp_path / "output",
temporary_dir=tmp_path / "temporary",
file_name="movie",
ffmpeg_path="/not-used-by-download-segments",
),
)
track = result.tracks[0]
assert [path.read_bytes() for path in track.segments] == [b"one", b"two"]
assert track.directory.is_dir()
assert not list((tmp_path / "output").glob("movie.*"))
shutil.rmtree(result.temporary_dir.parent)
assert not result.temporary_dir.exists()
def test_api_downloads_only_explicit_track_id(tmp_path: Path) -> None:
(tmp_path / "video.ts").write_bytes(b"video")
(tmp_path / "audio.ts").write_bytes(b"audio")