From 262efe8c0cae076b592d28b79e153c30b1933dc6 Mon Sep 17 00:00:00 2001 From: hyugogirubato <65763543+hyugogirubato@users.noreply.github.com> Date: Mon, 1 Apr 2024 12:24:00 +0200 Subject: [PATCH] Add ADB env check + auto start --- extractor/cdm.py | 4 ++++ keydive.py | 10 ++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/extractor/cdm.py b/extractor/cdm.py index 4814156..f5265ca 100644 --- a/extractor/cdm.py +++ b/extractor/cdm.py @@ -71,6 +71,10 @@ class Cdm: """ symbols = {} if path: + # Verify symbols file path + if not path.is_file(): + raise FileNotFoundError('Symbols file not found') + try: # Parse the XML file program = xmltodict.parse(path.read_bytes())['PROGRAM'] diff --git a/keydive.py b/keydive.py index 0b1c63f..af3d7e2 100644 --- a/keydive.py +++ b/keydive.py @@ -1,5 +1,6 @@ import argparse import logging +import subprocess import time import coloredlogs @@ -23,12 +24,13 @@ if __name__ == '__main__': args = parser.parse_args() try: - symbols = args.symbols - if symbols and not symbols.is_file(): - raise FileNotFoundError('Symbols file not found') + # Start ADB server + exitcode, _ = subprocess.getstatusoutput('adb start-server') + if exitcode != 0: + raise EnvironmentError('ADB is not recognized as an environment variable') # Initialize CDM handler with given device - cdm = Cdm(device=args.device, symbols=symbols) + cdm = Cdm(device=args.device, symbols=args.symbols) # Find Widevine process on the device process: Process = next((p for p in cdm.device.enumerate_processes() if cdm.vendor.process == p.name), None)