From 82d99d50d09f906a9b0f41606d50d9cf69a260c7 Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Sat, 30 Jul 2022 04:22:35 +0100 Subject: [PATCH] Cdm: Fix typing of type_ param on get_license_challenge() `LicenseType` shouldn't be used as a type-hint as its not a Type. --- pywidevine/cdm.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pywidevine/cdm.py b/pywidevine/cdm.py index ba6cdf4..839903a 100644 --- a/pywidevine/cdm.py +++ b/pywidevine/cdm.py @@ -152,7 +152,7 @@ class Cdm: self.service_certificate = drm_certificate return self.service_certificate.provider_id - def get_license_challenge(self, type_: LicenseType = LicenseType.STREAMING, privacy_mode: bool = True) -> bytes: + def get_license_challenge(self, type_: Union[int, str] = LicenseType.STREAMING, privacy_mode: bool = True) -> bytes: """ Get a License Challenge to send to a License Server. @@ -167,6 +167,9 @@ class Cdm: """ request_id = get_random_bytes(16) + if isinstance(type_, str): + type_ = LicenseType.Value(type_) + license_request = LicenseRequest() license_request.type = LicenseRequest.RequestType.Value("NEW") license_request.request_time = int(time.time())