From 4b330c0478e9ae6ff22c6fb6f294c20b192a32be Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Sat, 4 Mar 2023 11:18:28 +0000 Subject: [PATCH] Implement CEKNotFound and EmptyLicense exceptions to Widevine --- devine/core/drm/widevine.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/devine/core/drm/widevine.py b/devine/core/drm/widevine.py index 231def2..98752f1 100644 --- a/devine/core/drm/widevine.py +++ b/devine/core/drm/widevine.py @@ -210,10 +210,10 @@ class Widevine: for key in cdm.get_keys(session_id, "CONTENT") } if not self.content_keys: - raise ValueError("No Content Keys were returned by the License") + raise Widevine.Exceptions.EmptyLicense("No Content Keys were within the License") if kid not in self.content_keys: - raise ValueError(f"No Content Key with the KID ({kid.hex}) was returned") + raise Widevine.Exceptions.CEKNotFound(f"No Content Key for KID {kid.hex} within the License") finally: cdm.close(session_id) @@ -303,5 +303,11 @@ class Widevine: class KIDNotFound(Exception): """KID (Encryption Key ID) was not found.""" + class CEKNotFound(Exception): + """CEK (Content Encryption Key) for KID was not found in License.""" + + class EmptyLicense(Exception): + """License returned no Content Encryption Keys.""" + __ALL__ = (Widevine,)