forked from DRMTalks/devine
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_)
|
return aria2c(uri, out, headers, pproxy_)
|
||||||
arguments += ["--all-proxy", proxy]
|
arguments += ["--all-proxy", proxy]
|
||||||
|
|
||||||
|
try:
|
||||||
p = subprocess.Popen(
|
p = subprocess.Popen(
|
||||||
[executable, *arguments],
|
[executable, *arguments],
|
||||||
stdin=subprocess.PIPE,
|
stdin=subprocess.PIPE,
|
||||||
|
@ -94,7 +95,6 @@ def aria2c(
|
||||||
),
|
),
|
||||||
universal_newlines=True
|
universal_newlines=True
|
||||||
)
|
)
|
||||||
|
|
||||||
p._stdin_write(uri) # noqa
|
p._stdin_write(uri) # noqa
|
||||||
|
|
||||||
if progress:
|
if progress:
|
||||||
|
@ -130,6 +130,15 @@ def aria2c(
|
||||||
|
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
raise subprocess.CalledProcessError(p.returncode, arguments)
|
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
|
return p.returncode
|
||||||
|
|
||||||
|
|
|
@ -234,6 +234,7 @@ class Widevine:
|
||||||
|
|
||||||
decrypted_path = path.with_suffix(f".decrypted{path.suffix}")
|
decrypted_path = path.with_suffix(f".decrypted{path.suffix}")
|
||||||
config.directories.temp.mkdir(parents=True, exist_ok=True)
|
config.directories.temp.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
subprocess.check_call([
|
subprocess.check_call([
|
||||||
executable,
|
executable,
|
||||||
|
@ -253,6 +254,8 @@ class Widevine:
|
||||||
"--temp_dir", config.directories.temp
|
"--temp_dir", config.directories.temp
|
||||||
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||||
except subprocess.CalledProcessError as e:
|
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}")
|
raise subprocess.SubprocessError(f"Failed to Decrypt! Shaka Packager Error: {e}")
|
||||||
|
|
||||||
path.unlink()
|
path.unlink()
|
||||||
|
|
Loading…
Reference in New Issue