Extend functionality of migrate cmd to folders of wvds
This is so you can mass migrate devices instead of painfully one by one.
This commit is contained in:
parent
fc9a290482
commit
d9d8074f73
|
@ -241,25 +241,44 @@ def create_device(
|
||||||
|
|
||||||
|
|
||||||
@main.command()
|
@main.command()
|
||||||
@click.argument("device", type=Path)
|
@click.argument("path", type=Path)
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def migrate(ctx: click.Context, device: Path) -> None:
|
def migrate(ctx: click.Context, path: Path) -> None:
|
||||||
"""Upgrade from earlier versions of the Widevine Device (.wvd) format."""
|
"""
|
||||||
if not device.is_file():
|
Upgrade from earlier versions of the Widevine Device (.wvd) format.
|
||||||
raise click.UsageError("device: Not a path to a file, or it doesn't exist.", ctx)
|
|
||||||
|
The path argument can be a direct path to a Widevine Device (.wvd) file, or a path
|
||||||
|
to a folder of Widevine Devices files.
|
||||||
|
|
||||||
|
The migrated devices are saved to its original location, overwriting the old version.
|
||||||
|
"""
|
||||||
|
if not path.exists():
|
||||||
|
raise click.UsageError(f"path: The path '{path}' does not exist.", ctx)
|
||||||
|
|
||||||
log = logging.getLogger("migrate")
|
log = logging.getLogger("migrate")
|
||||||
|
|
||||||
try:
|
if path.is_dir():
|
||||||
new_device = Device.migrate(device.read_bytes())
|
devices = list(path.glob("*.wvd"))
|
||||||
except (ConstructError, ValueError) as e:
|
else:
|
||||||
raise click.UsageError(str(e), ctx)
|
devices = [path]
|
||||||
|
|
||||||
# save
|
migrated = 0
|
||||||
log.debug(new_device)
|
for device in devices:
|
||||||
new_device.dump(device)
|
log.info(f"Migrating {device.name}...")
|
||||||
|
|
||||||
log.info("Successfully migrated the Widevine Device (.wvd) file!")
|
try:
|
||||||
|
new_device = Device.migrate(device.read_bytes())
|
||||||
|
except (ConstructError, ValueError) as e:
|
||||||
|
log.error(f" - {e}")
|
||||||
|
continue
|
||||||
|
|
||||||
|
log.debug(new_device)
|
||||||
|
new_device.dump(device)
|
||||||
|
|
||||||
|
log.info(" + Success")
|
||||||
|
migrated += 1
|
||||||
|
|
||||||
|
log.info(f"Migrated {migrated}/{len(devices)} devices!")
|
||||||
|
|
||||||
|
|
||||||
@main.command("serve", short_help="Serve your local CDM and Widevine Devices Remotely.")
|
@main.command("serve", short_help="Serve your local CDM and Widevine Devices Remotely.")
|
||||||
|
|
Loading…
Reference in New Issue