From 29693bedf6f8e02b205cfd4ef1a39d865aafa9d0 Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Fri, 7 Jul 2023 19:42:59 +0100 Subject: [PATCH] Ensure output directory exists when using create-device --- pywidevine/main.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pywidevine/main.py b/pywidevine/main.py index 2d1d11b..95ade24 100644 --- a/pywidevine/main.py +++ b/pywidevine/main.py @@ -230,7 +230,13 @@ def create_device( except UnidecodeError as e: raise click.ClickException(f"Failed to sanitize name, {e}") - out_path = (output or Path.cwd()) / f"{name}_{device.system_id}_l{device.security_level}.wvd" + if output: + out_dir = output + out_dir.mkdir(parents=True, exist_ok=True) + else: + out_dir = Path.cwd() + + out_path = out_dir / f"{name}_{device.system_id}_l{device.security_level}.wvd" out_path.write_bytes(wvd_bin) log.info("Created Widevine Device (.wvd) file, %s", out_path.name)