Add ADB env check + auto start
This commit is contained in:
parent
3910b2b531
commit
262efe8c0c
|
@ -71,6 +71,10 @@ class Cdm:
|
||||||
"""
|
"""
|
||||||
symbols = {}
|
symbols = {}
|
||||||
if path:
|
if path:
|
||||||
|
# Verify symbols file path
|
||||||
|
if not path.is_file():
|
||||||
|
raise FileNotFoundError('Symbols file not found')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Parse the XML file
|
# Parse the XML file
|
||||||
program = xmltodict.parse(path.read_bytes())['PROGRAM']
|
program = xmltodict.parse(path.read_bytes())['PROGRAM']
|
||||||
|
|
10
keydive.py
10
keydive.py
|
@ -1,5 +1,6 @@
|
||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
|
import subprocess
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import coloredlogs
|
import coloredlogs
|
||||||
|
@ -23,12 +24,13 @@ if __name__ == '__main__':
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
symbols = args.symbols
|
# Start ADB server
|
||||||
if symbols and not symbols.is_file():
|
exitcode, _ = subprocess.getstatusoutput('adb start-server')
|
||||||
raise FileNotFoundError('Symbols file not found')
|
if exitcode != 0:
|
||||||
|
raise EnvironmentError('ADB is not recognized as an environment variable')
|
||||||
|
|
||||||
# Initialize CDM handler with given device
|
# 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
|
# Find Widevine process on the device
|
||||||
process: Process = next((p for p in cdm.device.enumerate_processes() if cdm.vendor.process == p.name), None)
|
process: Process = next((p for p in cdm.device.enumerate_processes() if cdm.vendor.process == p.name), None)
|
||||||
|
|
Loading…
Reference in New Issue