fix(drm): key PIFF-first tracks by track ID and trust shaka's exit code

mp4decrypt copied a track whose first sinf has no tenc through encrypted; pass its key by track ID and retry with shaka on a passthrough. Shaka fails only on a non-zero exit now.
This commit is contained in:
imSp4rky
2026-11-03 17:05:26 -07:00
parent 5ffdda3883
commit 893c81f428
14 changed files with 444 additions and 140 deletions
+1 -17
View File
@@ -23,26 +23,10 @@ class FakeDRM:
def __init__(self) -> None:
self.content_keys = {KID: KEY}
def mp4decrypt_key_args(self) -> list[str]:
def mp4decrypt_key_args(self, track_ids: object = ()) -> list[str]:
return ["--key", f"{KID.hex}:{KEY}", "--key", f"{ZERO_KID}:{KEY}"]
@pytest.fixture
def stub_mp4decrypt(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
"""An mp4decrypt that copies its input to its output and records its argv."""
argv_log = tmp_path / "argv.jsonl"
script = tmp_path / "mp4decrypt"
script.write_text(
"#!/usr/bin/env python3\n"
"import json, shutil, sys\n"
f"open({str(argv_log)!r}, 'a').write(json.dumps(sys.argv[1:]) + '\\n')\n"
"shutil.copyfile(sys.argv[-2], sys.argv[-1])\n"
)
script.chmod(0o755)
monkeypatch.setattr(binaries, "Mp4decrypt", script)
return argv_log
def read_argv(argv_log: Path) -> list[list[str]]:
return [json.loads(line) for line in argv_log.read_text().splitlines()]