mirror of
				https://github.com/devine-dl/devine.git
				synced 2025-11-04 03:44:49 +00:00 
			
		
		
		
	Re-raise errors when loading WVD files so it's more understandable
It also looks for the "expected 2 but parsed 1" error which is likely an error while parsing the WVD version field. If this happens, it will inform the user to use `pywidevine migrate`.
This commit is contained in:
		
							parent
							
								
									a24633fe61
								
							
						
					
					
						commit
						6a9598021d
					
				@ -24,6 +24,7 @@ import click
 | 
			
		||||
import jsonpickle
 | 
			
		||||
import pycaption
 | 
			
		||||
import yaml
 | 
			
		||||
from construct import ConstError
 | 
			
		||||
from pymediainfo import MediaInfo
 | 
			
		||||
from pywidevine.cdm import Cdm as WidevineCdm
 | 
			
		||||
from pywidevine.device import Device
 | 
			
		||||
@ -1023,5 +1024,14 @@ class dl:
 | 
			
		||||
        cdm_path = config.directories.wvds / f"{cdm_name}.wvd"
 | 
			
		||||
        if not cdm_path.is_file():
 | 
			
		||||
            raise ValueError(f"{cdm_name} does not exist or is not a file")
 | 
			
		||||
        device = Device.load(cdm_path)
 | 
			
		||||
 | 
			
		||||
        try:
 | 
			
		||||
            device = Device.load(cdm_path)
 | 
			
		||||
        except ConstError as e:
 | 
			
		||||
            if "expected 2 but parsed 1" in str(e):
 | 
			
		||||
                raise ValueError(
 | 
			
		||||
                    f"{cdm_name}.wvd seems to be a v1 WVD file, use `pywidevine migrate --help` to migrate it to v2."
 | 
			
		||||
                )
 | 
			
		||||
            raise ValueError(f"{cdm_name}.wvd is an invalid or corrupt Widevine Device file, {e}")
 | 
			
		||||
 | 
			
		||||
        return WidevineCdm.from_device(device)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user