mirror of
https://github.com/devine-dl/devine.git
synced 2025-04-30 01:59:44 +00:00
Ignore empty files when decrypting with Widevine
This happens because the input file has no actual useful data, likely just a bunch of headers and nothing of use. Therefore shaka skips and returns OK, yet didnt make any file at the decrypted path. This fixes a crash when it tries to move the non-existent decrypted file to the input file location, causing the rest of the download to halt.
This commit is contained in:
parent
f4a9d6c0b1
commit
bf3219b4e8
@ -258,11 +258,16 @@ class Widevine:
|
|||||||
universal_newlines=True
|
universal_newlines=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
stream_skipped = False
|
||||||
|
|
||||||
shaka_log_buffer = ""
|
shaka_log_buffer = ""
|
||||||
for line in iter(p.stderr.readline, ""):
|
for line in iter(p.stderr.readline, ""):
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
if not line:
|
if not line:
|
||||||
continue
|
continue
|
||||||
|
if "Skip stream" in line:
|
||||||
|
# file/segment was so small that it didn't have any actual data, ignore
|
||||||
|
stream_skipped = True
|
||||||
if ":INFO:" in line:
|
if ":INFO:" in line:
|
||||||
continue
|
continue
|
||||||
if "Insufficient bits in bitstream for given AVC profile" in line:
|
if "Insufficient bits in bitstream for given AVC profile" in line:
|
||||||
@ -283,14 +288,15 @@ class Widevine:
|
|||||||
|
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
raise subprocess.CalledProcessError(p.returncode, arguments)
|
raise subprocess.CalledProcessError(p.returncode, arguments)
|
||||||
|
|
||||||
|
path.unlink()
|
||||||
|
if not stream_skipped:
|
||||||
|
shutil.move(decrypted_path, path)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
if e.returncode == 0xC000013A: # STATUS_CONTROL_C_EXIT
|
if e.returncode == 0xC000013A: # STATUS_CONTROL_C_EXIT
|
||||||
raise KeyboardInterrupt()
|
raise KeyboardInterrupt()
|
||||||
raise
|
raise
|
||||||
|
|
||||||
path.unlink()
|
|
||||||
shutil.move(decrypted_path, path)
|
|
||||||
|
|
||||||
class Exceptions:
|
class Exceptions:
|
||||||
class PSSHNotFound(Exception):
|
class PSSHNotFound(Exception):
|
||||||
"""PSSH (Protection System Specific Header) was not found."""
|
"""PSSH (Protection System Specific Header) was not found."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user