mirror of
				https://github.com/devine-dl/pywidevine.git
				synced 2025-11-04 03:44:50 +00:00 
			
		
		
		
	Add ability to specify output filename when using create-device
This commit is contained in:
		
							parent
							
								
									29693bedf6
								
							
						
					
					
						commit
						728a3e7575
					
				@ -176,7 +176,7 @@ def test(ctx: click.Context, device: Path, privacy: bool):
 | 
				
			|||||||
@click.option("-k", "--key", type=Path, required=True, help="Device RSA Private Key in PEM or DER format")
 | 
					@click.option("-k", "--key", type=Path, required=True, help="Device RSA Private Key in PEM or DER format")
 | 
				
			||||||
@click.option("-c", "--client_id", type=Path, required=True, help="Widevine ClientIdentification Blob file")
 | 
					@click.option("-c", "--client_id", type=Path, required=True, help="Widevine ClientIdentification Blob file")
 | 
				
			||||||
@click.option("-v", "--vmp", type=Path, default=None, help="Widevine FileHashes Blob file")
 | 
					@click.option("-v", "--vmp", type=Path, default=None, help="Widevine FileHashes Blob file")
 | 
				
			||||||
@click.option("-o", "--output", type=Path, default=None, help="Output Directory")
 | 
					@click.option("-o", "--output", type=Path, default=None, help="Output Path or Directory")
 | 
				
			||||||
@click.pass_context
 | 
					@click.pass_context
 | 
				
			||||||
def create_device(
 | 
					def create_device(
 | 
				
			||||||
    ctx: click.Context,
 | 
					    ctx: click.Context,
 | 
				
			||||||
@ -230,13 +230,15 @@ def create_device(
 | 
				
			|||||||
    except UnidecodeError as e:
 | 
					    except UnidecodeError as e:
 | 
				
			||||||
        raise click.ClickException(f"Failed to sanitize name, {e}")
 | 
					        raise click.ClickException(f"Failed to sanitize name, {e}")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if output:
 | 
					    if output and output.suffix:
 | 
				
			||||||
        out_dir = output
 | 
					        if output.suffix.lower() != ".wvd":
 | 
				
			||||||
        out_dir.mkdir(parents=True, exist_ok=True)
 | 
					            log.warning(f"Saving WVD with the file extension '{output.suffix}' but '.wvd' is recommended.")
 | 
				
			||||||
 | 
					        out_path = output
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        out_dir = Path.cwd()
 | 
					        out_dir = output or Path.cwd()
 | 
				
			||||||
 | 
					        out_path = out_dir / f"{name}_{device.system_id}_l{device.security_level}.wvd"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    out_path = out_dir / f"{name}_{device.system_id}_l{device.security_level}.wvd"
 | 
					    out_path.parent.mkdir(parents=True, exist_ok=True)
 | 
				
			||||||
    out_path.write_bytes(wvd_bin)
 | 
					    out_path.write_bytes(wvd_bin)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    log.info("Created Widevine Device (.wvd) file, %s", out_path.name)
 | 
					    log.info("Created Widevine Device (.wvd) file, %s", out_path.name)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user