ldplayer abstraction layer for python (bundled with a CLI with batch support).
Project description
LDPX - LDPlayer Automation Toolkit
A powerful Python abstraction layer and CLI tool for controlling LDPlayer Android emulator instances. Manage multiple emulators programmatically with comprehensive batch operation support.
Features
- 🐍 Python API: Complete wrapper for all ldconsole commands
- 🚀 Batch Operations: Execute commands across multiple instances simultaneously
- 🔍 Auto-Discovery: Automatically detect LDPlayer installations
- ⚙️ Configuration Management: Read and modify emulator configs programmatically
- 🎯 Flexible Targeting: Select instances by name, index, list, or lambda filter
- 💾 Smart Caching: LFU cache for configuration files with automatic staleness detection
- 📝 Type-Safe: Full type hints and comprehensive docstrings
- 🛠️ CLI Tool: Intuitive command-line interface built with Click
Installation
Using uv (recommended)
# With CLI support
uv add ldpx[click]
# API only
uv add ldpx
Using pip
# With CLI support
pip install ldpx[click]
# API only
pip install ldpx
Quick Start
Auto-Discovery
# Discover LDPlayer installation automatically
ldpx discover
# Verify configuration
ldpx console query list2
Python API
from ldpx.core.objs.attr import LDAttr
from ldpx.core.objs.console import Console
# Initialize (auto-discover or load from config)
attr = LDAttr.discover()
console = Console(attr)
# Single instance operations
console.launch(name="instance1")
console.installapp(index=0, filename="app.apk")
# Batch operations - by list
console.launch([0, 1, 2])
# Batch operations - by lambda filter
console.launch(instances=lambda x: x.name.startswith('game'))
# Query instances
instances = console.list2()
for inst in instances:
print(f"{inst['name']}: {inst['id']}")
CLI Usage
# Launch single instance
ldpx console exec launch --name instance1
# Batch launch by indices
ldpx console exec launch -bs "0,1,2"
# Batch launch by lambda filter
ldpx console exec launch -bl "lambda x: x['name'].startswith('game')"
# Install app on multiple instances
ldpx console app installapp --filename app.apk -bs "0,1,2"
# Query instance information
ldpx console query list2
ldpx console query isrunning --name instance1
# Modify instance settings
ldpx console config modify --name instance1 --resolution "1920x1080" --cpu 4 --memory 4096
Command Categories
Query Commands
Get information about emulator instances:
list- List all instances (simple format)list2- List all instances (detailed metadata)list3- Query single instance detailsrunninglist- List running instancesisrunning- Check if instance is runninggetprop- Get system property valueoperatelist- List operations for instanceoperateinfo- Get operation information
Execution Commands
Control emulator lifecycle:
launch- Start an emulator instancequit- Stop an emulator instancereboot- Reboot an emulator instancequitall- Stop all running instancesadd- Create new emulator instancecopy- Clone an existing instanceremove- Delete an emulator instancerename- Rename an emulator instance
App Management
Manage Android applications:
installapp- Install APK file or app by package nameuninstallapp- Uninstall app by package namerunapp- Launch an appkillapp- Stop a running applaunchex- Launch app with extended optionsbackupapp- Backup app and its datarestoreapp- Restore app and its data
Configuration
Modify emulator settings:
modify- Change instance settings (CPU, memory, resolution, device info, etc.)globalsetting- Configure global settings (FPS, audio, etc.)operaterecord- Execute recorded macro/script
File Operations
Transfer files between host and emulator:
pull- Download files from emulatorpush- Upload files to emulator
Simple Commands
Utility commands:
rock- Shake the emulator windowzoomIn- Zoom in the emulator windowzoomOut- Zoom out the emulator windowsortWnd- Sort and arrange emulator windows
Batch Operations
Batch operations allow you to execute commands on multiple instances at once.
By Comma-Separated List
# Indices
ldpx console exec launch -bs "0,1,2"
# Names
ldpx console exec launch -bs "instance1,instance2,instance3"
By Lambda Filter
# Filter by name pattern
ldpx console exec launch -bl "lambda x: x['name'].startswith('game')"
# Filter by running status
ldpx console exec quit -bl "lambda x: x['android_started_int'] == 1"
Python API Batch
# List of indices
console.launch([0, 1, 2])
# List of names
console.launch(["instance1", "instance2"])
# Lambda filter
console.launch(instances=lambda x: x['name'].startswith('test'))
# Custom function
console.launch(console_func=lambda c: c.launch(name='specific'))
Configuration Management
from ldpx.ext.obj.leidian import LeidianFile
# Initialize
leidian_file = LeidianFile(attr)
# Get global configuration
global_config = leidian_file.getLeidiansConfig()
# Get instance configuration
instance_config = leidian_file.getLeidianConfig(0)
# Modify and save
instance_config.basicSettings['fps'] = 120
leidian_file.dumpLeidianConfig(instance_config)
Advanced Features
Keyboard Mapping Management
from ldpx.ext.obj.kmp import KMPFile
kmp_file = KMPFile(attr)
# List available mappings
mappings = kmp_file.customizeList()
# Load a mapping
mapping = kmp_file.getCustomize("game_mapping.kmp")
# Modify and save
# ... modify mapping ...
kmp_file.dump("game_mapping.kmp", mapping)
Macro/Script Management
from ldpx.ext.obj.record import RecordFile
record_file = RecordFile(attr)
# List recordings
recordings = record_file.recordList()
# Load a recording
record = record_file.getRecord("automation.record")
# Execute on instance
console.operaterecord(name="instance1", content=record)
Requirements
- Python 3.12 or higher
- Windows OS (LDPlayer is Windows-only)
- LDPlayer installed
- psutil for process discovery
- click for CLI (optional)
Configuration
LDPX stores configuration in ~/.ldpx/ld/config.json:
{
"path": [
"C:/path/to/LDPlayer",
"D:/another/installation"
]
}
Add paths manually or use ldpx discover for automatic detection.
Documentation
Full API documentation with docstrings is available in the source code. Each module, class, and function includes comprehensive documentation.
Contributing
Contributions welcome! Please ensure:
- Code follows existing patterns
- Type hints are included
- Docstrings are comprehensive
- Tests pass (when test suite is added)
License
MIT License - see LICENSE file for details
Acknowledgments
- LDPlayer for providing the ldconsole CLI tool
- Click framework for CLI capabilities
- psutil for process management
Support
For issues, questions, or contributions, please visit the project repository.
Note: This tool requires LDPlayer to be installed and is Windows-only due to LDPlayer platform constraints.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ldpx-0.3.0.tar.gz.
File metadata
- Download URL: ldpx-0.3.0.tar.gz
- Upload date:
- Size: 30.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2704cdf76e7961819e6a2720e98203049c9be80897f64eb2a4ccd8fd29ee0a45
|
|
| MD5 |
3de3c97817d60b3fddc46cbe49ea5b98
|
|
| BLAKE2b-256 |
89bb4d3ec848c4adde480e5c19b0c6b3e831f77a902b38467e2e08f28cb4f361
|
Provenance
The following attestation bundles were made for ldpx-0.3.0.tar.gz:
Publisher:
main-publish.yml on ZackaryW/ldpx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ldpx-0.3.0.tar.gz -
Subject digest:
2704cdf76e7961819e6a2720e98203049c9be80897f64eb2a4ccd8fd29ee0a45 - Sigstore transparency entry: 660840655
- Sigstore integration time:
-
Permalink:
ZackaryW/ldpx@213c27606080ffe82f05ebf2ca078af96355d6e1 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/ZackaryW
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main-publish.yml@213c27606080ffe82f05ebf2ca078af96355d6e1 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ldpx-0.3.0-py3-none-any.whl.
File metadata
- Download URL: ldpx-0.3.0-py3-none-any.whl
- Upload date:
- Size: 45.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82be2b71f9a6df3d18ba81756dd57d1615651ea3165d29f2ed5a729d9d82acfa
|
|
| MD5 |
aed08fe8d95d25007829b41e05d88a8c
|
|
| BLAKE2b-256 |
bb867588479df36eb47d3a42d8fde0527c2b5e18684a28f4b2917f7161d40d96
|
Provenance
The following attestation bundles were made for ldpx-0.3.0-py3-none-any.whl:
Publisher:
main-publish.yml on ZackaryW/ldpx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ldpx-0.3.0-py3-none-any.whl -
Subject digest:
82be2b71f9a6df3d18ba81756dd57d1615651ea3165d29f2ed5a729d9d82acfa - Sigstore transparency entry: 660840657
- Sigstore integration time:
-
Permalink:
ZackaryW/ldpx@213c27606080ffe82f05ebf2ca078af96355d6e1 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/ZackaryW
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main-publish.yml@213c27606080ffe82f05ebf2ca078af96355d6e1 -
Trigger Event:
push
-
Statement type: