mirror of https://github.com/devine-dl/devine.git
Pass shaka-packager & aria CTRL+C to caller as KeyboardInterrupt()s
This commit is contained in:
parent
ad1990cc42
commit
8365d798a4
|
@ -83,6 +83,7 @@ def aria2c(
|
|||
return aria2c(uri, out, headers, pproxy_)
|
||||
arguments += ["--all-proxy", proxy]
|
||||
|
||||
try:
|
||||
p = subprocess.Popen(
|
||||
[executable, *arguments],
|
||||
stdin=subprocess.PIPE,
|
||||
|
@ -94,7 +95,6 @@ def aria2c(
|
|||
),
|
||||
universal_newlines=True
|
||||
)
|
||||
|
||||
p._stdin_write(uri) # noqa
|
||||
|
||||
if progress:
|
||||
|
@ -130,6 +130,15 @@ def aria2c(
|
|||
|
||||
if p.returncode != 0:
|
||||
raise subprocess.CalledProcessError(p.returncode, arguments)
|
||||
except ConnectionResetError:
|
||||
# interrupted while passing URI to download
|
||||
raise KeyboardInterrupt()
|
||||
except subprocess.CalledProcessError as e:
|
||||
if e.returncode in (7, 0xC000013A):
|
||||
# 7 is when Aria2(c) handled the CTRL+C
|
||||
# 0xC000013A is when it never got the chance to
|
||||
raise KeyboardInterrupt()
|
||||
raise
|
||||
|
||||
return p.returncode
|
||||
|
||||
|
|
|
@ -234,6 +234,7 @@ class Widevine:
|
|||
|
||||
decrypted_path = path.with_suffix(f".decrypted{path.suffix}")
|
||||
config.directories.temp.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
try:
|
||||
subprocess.check_call([
|
||||
executable,
|
||||
|
@ -253,6 +254,8 @@ class Widevine:
|
|||
"--temp_dir", config.directories.temp
|
||||
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
except subprocess.CalledProcessError as e:
|
||||
if e.returncode == 0xC000013A: # STATUS_CONTROL_C_EXIT
|
||||
raise KeyboardInterrupt()
|
||||
raise subprocess.SubprocessError(f"Failed to Decrypt! Shaka Packager Error: {e}")
|
||||
|
||||
path.unlink()
|
||||
|
|
Loading…
Reference in New Issue