Allow specification of Cdm device_type as string

This commit is contained in:
rlaphoenix 2022-08-04 08:26:41 +01:00
parent 5b13e1a689
commit a1494a3742
2 changed files with 6 additions and 2 deletions

View File

@ -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}")

View File

@ -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}")