forked from kenzuya/unshackle
fix(drm): keep the track file when shaka-packager skips a stream with no samples
This commit is contained in:
@@ -115,6 +115,7 @@ def shaka_decrypt(path: Path, keys: str, label: str) -> None:
|
||||
"""Decrypt ``path`` in place with shaka-packager and its ``--keys`` value ``keys``.
|
||||
|
||||
Only a non-zero exit is a failure; its non-noise log lines go to the console under ``[label]``.
|
||||
A track that shaka-packager skips because it has no samples leaves ``path`` as it is.
|
||||
"""
|
||||
if not binaries.ShakaPackager:
|
||||
raise coded(OSError("Shaka Packager executable not found but is required."), APIErrorCode.DRM_ERROR)
|
||||
@@ -149,7 +150,6 @@ def shaka_decrypt(path: Path, keys: str, label: str) -> None:
|
||||
if not line:
|
||||
continue
|
||||
if "Skip stream" in line:
|
||||
# file/segment was so small that it didn't have any actual data, ignore
|
||||
stream_skipped = True
|
||||
if shaka_noise(line):
|
||||
continue
|
||||
@@ -165,9 +165,11 @@ def shaka_decrypt(path: Path, keys: str, label: str) -> None:
|
||||
console.log(Text.from_ansi(f"\n[{label}]: " + shaka_log_buffer))
|
||||
raise subprocess.CalledProcessError(p.returncode, [binaries.ShakaPackager, *arguments])
|
||||
|
||||
path.unlink()
|
||||
if not stream_skipped:
|
||||
shutil.move(output_path, path)
|
||||
if stream_skipped:
|
||||
log.warning(f"shaka-packager found no samples in {path.name}, kept the file as it is")
|
||||
output_path.unlink(missing_ok=True)
|
||||
else:
|
||||
output_path.replace(path)
|
||||
except subprocess.CalledProcessError as e:
|
||||
if e.returncode == 0xC000013A: # STATUS_CONTROL_C_EXIT
|
||||
raise KeyboardInterrupt() from None
|
||||
|
||||
Reference in New Issue
Block a user