mirror of
				https://github.com/devine-dl/pywidevine.git
				synced 2025-11-04 03:44:50 +00:00 
			
		
		
		
	Allow specification of Cdm device_type as string
This commit is contained in:
		
							parent
							
								
									5b13e1a689
								
							
						
					
					
						commit
						a1494a3742
					
				@ -66,7 +66,7 @@ class Cdm:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    def __init__(
 | 
					    def __init__(
 | 
				
			||||||
        self,
 | 
					        self,
 | 
				
			||||||
        device_type: Device.Types,
 | 
					        device_type: Union[Device.Types, str],
 | 
				
			||||||
        system_id: int,
 | 
					        system_id: int,
 | 
				
			||||||
        security_level: int,
 | 
					        security_level: int,
 | 
				
			||||||
        client_id: ClientIdentification,
 | 
					        client_id: ClientIdentification,
 | 
				
			||||||
@ -75,6 +75,8 @@ class Cdm:
 | 
				
			|||||||
        """Initialize a Widevine Content Decryption Module (CDM)."""
 | 
					        """Initialize a Widevine Content Decryption Module (CDM)."""
 | 
				
			||||||
        if not device_type:
 | 
					        if not device_type:
 | 
				
			||||||
            raise ValueError("Device Type must be provided")
 | 
					            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):
 | 
					        if not isinstance(device_type, Device.Types):
 | 
				
			||||||
            raise TypeError(f"Expected device_type to be a {Device.Types!r} not {device_type!r}")
 | 
					            raise TypeError(f"Expected device_type to be a {Device.Types!r} not {device_type!r}")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -24,7 +24,7 @@ class RemoteCdm(Cdm):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    def __init__(
 | 
					    def __init__(
 | 
				
			||||||
        self,
 | 
					        self,
 | 
				
			||||||
        device_type: Device.Types,
 | 
					        device_type: Union[Device.Types, str],
 | 
				
			||||||
        system_id: int,
 | 
					        system_id: int,
 | 
				
			||||||
        security_level: int,
 | 
					        security_level: int,
 | 
				
			||||||
        host: str,
 | 
					        host: str,
 | 
				
			||||||
@ -34,6 +34,8 @@ class RemoteCdm(Cdm):
 | 
				
			|||||||
        """Initialize a Widevine Content Decryption Module (CDM)."""
 | 
					        """Initialize a Widevine Content Decryption Module (CDM)."""
 | 
				
			||||||
        if not device_type:
 | 
					        if not device_type:
 | 
				
			||||||
            raise ValueError("Device Type must be provided")
 | 
					            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):
 | 
					        if not isinstance(device_type, Device.Types):
 | 
				
			||||||
            raise TypeError(f"Expected device_type to be a {Device.Types!r} not {device_type!r}")
 | 
					            raise TypeError(f"Expected device_type to be a {Device.Types!r} not {device_type!r}")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user