forked from DRMTalks/devine
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
|
||||
)
|
||||
|
||||
stream_skipped = False
|
||||
|
||||
shaka_log_buffer = ""
|
||||
for line in iter(p.stderr.readline, ""):
|
||||
line = line.strip()
|
||||
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 ":INFO:" in line:
|
||||
continue
|
||||
if "Insufficient bits in bitstream for given AVC profile" in line:
|
||||
|
@ -283,14 +288,15 @@ class Widevine:
|
|||
|
||||
if p.returncode != 0:
|
||||
raise subprocess.CalledProcessError(p.returncode, arguments)
|
||||
|
||||
path.unlink()
|
||||
if not stream_skipped:
|
||||
shutil.move(decrypted_path, path)
|
||||
except subprocess.CalledProcessError as e:
|
||||
if e.returncode == 0xC000013A: # STATUS_CONTROL_C_EXIT
|
||||
raise KeyboardInterrupt()
|
||||
raise
|
||||
|
||||
path.unlink()
|
||||
shutil.move(decrypted_path, path)
|
||||
|
||||
class Exceptions:
|
||||
class PSSHNotFound(Exception):
|
||||
"""PSSH (Protection System Specific Header) was not found."""
|
||||
|
|
Loading…
Reference in New Issue