mirror of
				https://github.com/devine-dl/devine.git
				synced 2025-11-03 19:34:49 +00:00 
			
		
		
		
	refactor(dl): Make Widevine CDM config optional
With this change you no longer have to define/configure a CDM to load. This is something that isn't necessary for a lot of services. Note: It's also now less hand-holdy in terms of correct config formatting/values. I.e. if you define a cdm by profile for a service slightly incorrectly, say a typo on the service or profile name, it will no longer warn you.
This commit is contained in:
		
							parent
							
								
									0310646cb2
								
							
						
					
					
						commit
						221cd145c4
					
				@ -178,9 +178,10 @@ class dl:
 | 
				
			|||||||
            except ValueError as e:
 | 
					            except ValueError as e:
 | 
				
			||||||
                self.log.error(f"Failed to load Widevine CDM, {e}")
 | 
					                self.log.error(f"Failed to load Widevine CDM, {e}")
 | 
				
			||||||
                sys.exit(1)
 | 
					                sys.exit(1)
 | 
				
			||||||
            self.log.info(
 | 
					            if self.cdm:
 | 
				
			||||||
                f"Loaded {self.cdm.__class__.__name__} Widevine CDM: {self.cdm.system_id} (L{self.cdm.security_level})"
 | 
					                self.log.info(
 | 
				
			||||||
            )
 | 
					                    f"Loaded {self.cdm.__class__.__name__} Widevine CDM: {self.cdm.system_id} (L{self.cdm.security_level})"
 | 
				
			||||||
 | 
					                )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        with console.status("Loading Key Vaults...", spinner="dots"):
 | 
					        with console.status("Loading Key Vaults...", spinner="dots"):
 | 
				
			||||||
            self.vaults = Vaults(self.service)
 | 
					            self.vaults = Vaults(self.service)
 | 
				
			||||||
@ -936,21 +937,21 @@ class dl:
 | 
				
			|||||||
                return Credential.loads(credentials)  # type: ignore
 | 
					                return Credential.loads(credentials)  # type: ignore
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @staticmethod
 | 
					    @staticmethod
 | 
				
			||||||
    def get_cdm(service: str, profile: Optional[str] = None) -> WidevineCdm:
 | 
					    def get_cdm(service: str, profile: Optional[str] = None) -> Optional[WidevineCdm]:
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        Get CDM for a specified service (either Local or Remote CDM).
 | 
					        Get CDM for a specified service (either Local or Remote CDM).
 | 
				
			||||||
        Raises a ValueError if there's a problem getting a CDM.
 | 
					        Raises a ValueError if there's a problem getting a CDM.
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        cdm_name = config.cdm.get(service) or config.cdm.get("default")
 | 
					        cdm_name = config.cdm.get(service) or config.cdm.get("default")
 | 
				
			||||||
        if not cdm_name:
 | 
					        if not cdm_name:
 | 
				
			||||||
            raise ValueError("A CDM to use wasn't listed in the config")
 | 
					            return None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if isinstance(cdm_name, dict):
 | 
					        if isinstance(cdm_name, dict):
 | 
				
			||||||
            if not profile:
 | 
					            if not profile:
 | 
				
			||||||
                raise ValueError("CDM config is mapped for profiles, but no profile was chosen")
 | 
					                return None
 | 
				
			||||||
            cdm_name = cdm_name.get(profile) or config.cdm.get("default")
 | 
					            cdm_name = cdm_name.get(profile) or config.cdm.get("default")
 | 
				
			||||||
            if not cdm_name:
 | 
					            if not cdm_name:
 | 
				
			||||||
                raise ValueError(f"A CDM to use was not mapped for the profile {profile}")
 | 
					                return None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        cdm_api = next(iter(x for x in config.remote_cdm if x["name"] == cdm_name), None)
 | 
					        cdm_api = next(iter(x for x in config.remote_cdm if x["name"] == cdm_name), None)
 | 
				
			||||||
        if cdm_api:
 | 
					        if cdm_api:
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user