mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-15 13:35:05 +00:00
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:
@@ -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()]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user