From a1494a3742c71f7e31993ea41dc0fafb1ead3cc9 Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Thu, 4 Aug 2022 08:26:41 +0100 Subject: [PATCH] Allow specification of Cdm device_type as string --- pywidevine/cdm.py | 4 +++- pywidevine/remotecdm.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pywidevine/cdm.py b/pywidevine/cdm.py index f0f76f4..56b93ed 100644 --- a/pywidevine/cdm.py +++ b/pywidevine/cdm.py @@ -66,7 +66,7 @@ class Cdm: def __init__( self, - device_type: Device.Types, + device_type: Union[Device.Types, str], system_id: int, security_level: int, client_id: ClientIdentification, @@ -75,6 +75,8 @@ class Cdm: """Initialize a Widevine Content Decryption Module (CDM).""" if not device_type: raise ValueError("Device Type must be provided") + if isinstance(device_type, str): + device_type = Device.Types[device_type] if not isinstance(device_type, Device.Types): raise TypeError(f"Expected device_type to be a {Device.Types!r} not {device_type!r}") diff --git a/pywidevine/remotecdm.py b/pywidevine/remotecdm.py index 1786427..be7ed22 100644 --- a/pywidevine/remotecdm.py +++ b/pywidevine/remotecdm.py @@ -24,7 +24,7 @@ class RemoteCdm(Cdm): def __init__( self, - device_type: Device.Types, + device_type: Union[Device.Types, str], system_id: int, security_level: int, host: str, @@ -34,6 +34,8 @@ class RemoteCdm(Cdm): """Initialize a Widevine Content Decryption Module (CDM).""" if not device_type: raise ValueError("Device Type must be provided") + if isinstance(device_type, str): + device_type = Device.Types[device_type] if not isinstance(device_type, Device.Types): raise TypeError(f"Expected device_type to be a {Device.Types!r} not {device_type!r}")